Calling Python code from inside php

Tobiah toby at tobiah.org
Wed Apr 23 15:17:06 EDT 2008


On Wed, 23 Apr 2008 20:42:44 +0200, Diez B. Roggisch wrote:

> vijay schrieb:
>> Hi
>>     I have a python code performing some computation for me.I have a
>> html page which passes certain argumnets to a php page.This php page
>> needs to pass on the value to the Python class and get the result
>> back.
>> How do I go about this??


I do this quite a bit:

<?php

#***** GET OUTPUT OF PYTHON PROGRAM *****
$command = "/some/directory/report.py arg1 arg2 2>&1";
$p = popen($command, 'r');

$output = fread($p, 1024 * 1024);

print $output;

?>

** Posted from http://www.teranews.com **



More information about the Python-list mailing list