I'm launching a Python script from PHP and I'd like to get the line printed from that Python:
exec( "python plotModule.py $myArray[0] $myArray[1]", $output, $ret_code);
$fp = fopen('logDisp.txt', 'w');
fwrite($fp, "$output");
fclose($fp);
In Python I have a print("hello")
in order to test if it's working. Nothing is written in logDisp.txt file.
Can you tell me why?
You try write $output as string, but it`s an array
Use foreach or $output[0]
exec( "python plotModule.py $myArray[0] $myArray[1]", $output, $ret_code);
$fp = fopen('logDisp.txt', 'w');
fwrite($fp, json_encode($output));
fclose($fp);
Here you can see the jsonified response
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.