Is it possible to use Python with php

You could have a look at PiP

To that end, I've [site author] written a Python extension for PHP. In short, this extensions allows the Python interpretter to be embedded inside of PHP (think of PHP as the parent language with Python as its child). This allows native Python objects to be instantiated and manipulated from within PHP. There is also initial support for accessing PHP functions and data from within the embedded Python environment.

However, I cannot comment on its reliability. Might need to test it for yourself.


I think that should be

<?php 

$try = exec("/var/htdocs/folder/test.py")

?>

Try and see if it works


You can execute python scripts using the exec() function in your php script.

Also this seems to provide an answer or two to your question.

Calling Python in PHP


You're trying to do something like

def helloWorld():
    print 'Hello, World'

<?php helloWorld(); ?>

I'd say that you most certainly can't.

Edit: Have a look at php's shell_exec though.

Tags:

Python

Php