Pass php variables values to python script

Assume the following php code:

example.php

<?php
$var1 = "1";
$var2 = "2";
$var3 = "3";
$output = exec("example.py ".$var1." ".$var2." ".$var3);
print $output;

?>

$output variable contains python's script output

Then we have to create the example.py script.

example.py 

import sys

print sys.argv[1], sys.argv[2], sys.argv[3] 


Comments

Popular posts from this blog

Vertex Cover (python implementation)

Transportation Problem (Vogel algorithm python)

cProfile python (benchmark)