> It's possible, but not very efficient.
>
> You can execute a Python script from PHP using the exec() function:
> PHP Code:
>
> exec("python /path/to/python-script.py");
>
>
>
> There are also a variety of similar PHP functions that can be used to
> accomplish the same thing with minor differences to the way input and
> output are handled (passthru, system, proc_open, backticks).
>
> The Python script will be executed using its command line interface -
> not using CGI (or similar) interface as you would have if the web
> server were directly executing the Python script. This means that the
> Python script will not have access to information about the HTTP
> request - GET/POST values, the client's IP address, the page URL, etc.
> You could pass this information from PHP to Python using command line
> parameters, a pipe, a temporary file or some other form of
> inter-process communication, but you need to pass each piece of
> required information explicitly.
>
> The reason this is inefficient is because every call to exec will
> spawn a whole new process for the Python script. That's a fairly
> expensive operation to do on every HTTP request (this is why servers
> like Apache and interfaces like Fast-CGI re-use child processes and
> threads instead of creating new ones). Additionally, if you have more
> than one call to exec, every single one is going to spawn a new
> process.
Extracted from [here][1].
More info :
[To see links please register here]
[1]:
[To see links please register here]