I need a PHP code that outputs an image generated by matplotlib. The input is given by PHP, while python processes it and returns an image.
For this matter, I'm trying to "call python" via PHP.
I've already tried exec()
, popen()
, proc_open()
, system()
, shell_exec()
and even backticks
(the last two seem to be currently disabled).
I know that I should use proc_open()
for my project, but I can't even display a simple "Hello World" with any of these functions.
Even after researching in forums and reading the PHP documentation, the result is always blank.
What should I do?
Here is a sample code that, doesn't output anything for me:
PHP file:
<?php
$pyscript = 'C:\wamp64\www\my_folder\test.py';
$pypath = 'C:\Python36\python.exe';
$cmd='$pyscript $pypath';
exec("$cmd", $output);
echo $output;
?>
Python File:
print("Hello World")