Python Script Failing to Execute from PHP exec()

后端 未结 4 1914
死守一世寂寞
死守一世寂寞 2020-12-19 10:08

I have a simple PHP function that is supposed to execute a Pyton script when its called. I have tried this sort of function multiple times in my php programs, but somehow th

4条回答
  •  情歌与酒
    2020-12-19 10:38

    Try removing the $mystring; line

    function success() {
       $mystring = exec('python testing.py');
       if(!$mystring){
           echo "python exec failed";
       } else {
           echo "
    "; echo "successfully executed!"; } }

    For testing purposes try:

    function success() {
       $mystring = exec('python testing.py', $output);
       var_dump($output);
    }
    

提交回复
热议问题