Pip - Running Python within PHP

Study group dedicated to learning how to code in the Python language.

Moderators: snarkout, Patrick, dann

Post Reply
User avatar
Posts: 466
Joined: Sun Oct 30, 2005 7:01 pm
Location: Mexico

Pip - Running Python within PHP

Post by Jza » Fri May 04, 2007 8:13 pm

If anyone have tried to use mod_python, it knows the issues on configuring Python to develop for the web. However with this implementation you could run python code within PHP.

Unfortunately the extensions is very alpha and even if it's old it, the development hasn't been that fast. Actually is a bit stalled.

However here is a code sample:

Code: Select all

$a = "test";
$b = true;
$c = 50;
$d = 60.4;

$code = <<<EOD
import php

a = php.var('a')
b = php.var('b')
c = php.var('c')
d = php.var('d')

print a, b, c, d
print a, d / c + b, a


Code: Select all

test 1 50 60.4
test 2.208 test
What is worst it seem to only work on python 2.3 and php4.x. I havent seen a package for php5.
Alexandro COLORADO

Post Reply