PHP exec to run a file

前端 未结 2 971
天命终不由人
天命终不由人 2020-12-20 17:53

I am trying for last 3 hours to tell PHP to run a simple file. I am using wamp server for windows in local host (Windows 8)

I\'ve tried with exec() work

相关标签:
2条回答
  • 2020-12-20 18:39

    Give the full path to the PHP executable and the full path to the PHP script. You can save the output in $output to see what the script produced:

    exec("d:/path/to/php.exe d:/wamp/www/diplomski/program/defender/tester.php", $output);
    print_r($output);
    
    0 讨论(0)
  • 2020-12-20 18:52

    1) What version of php? If it is older then 5.4.0 php can be in safe mode, when safe mode is enabled, you can only execute files within the safe_mode_exec_dir.

    2)Note to this function in php.net Note:

    If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.
    

    3) So you can try this How to make php script run another php script you can try this

     <?php
     $somearg = escapeshellarg('blah');
     exec("php file2.php $somearg > /dev/null &");
    

    4) You can create a scheduled task How to run a PHP file in a scheduled task (Windows Task Scheduler)

    0 讨论(0)
提交回复
热议问题