I've tried to send data from php to python, I found a tutorial from here.
this is the code.
php
<?php
$data = array('1','4','67','34');
$result = shell_exec('python try.py ' . escapeshellarg(json_encode($data)));
$resultData = json_decode($result, true)
var_dump($resultData);
?>
python
#!/Python27/python
import sys, json
# Load the data that PHP sent us
try:
data = json.loads(sys.argv[1])
except:
print "ERROR"
sys.exit(1)
# Send it to stdout (to PHP)
print json.dumps(data)
and output:
array(4) {
[0]=>
int(1)
[1]=>
int(4)
[2]=>
int(67)
[3]=>
int(34)
}
I try and succeed, but it's just an integer, I want a string.
I tried to replace the data
$data = array('tiger','dog','cow','lion');
but the result is NULL