Execute php script in a bat file: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 21: Line 21:


Options "-f <file>        Parse and execute <file>."<ref>[http://php.net/manual/en/features.commandline.options.php PHP: Options - Manual]</ref>
Options "-f <file>        Parse and execute <file>."<ref>[http://php.net/manual/en/features.commandline.options.php PHP: Options - Manual]</ref>
== Sample bat file ==
<pre>
@ECHO OFF
c:\path\to\php.exe "c:\path\to\php_script.php" -var1=value1
PAUSE
</pre>
instruction:
* [https://www.computerhope.com/echohlp.htm MS-DOS echo command help]
* {{kbd | key=<nowiki>PAUSE</nowiki>}} at the end of file to prevent auto closing of console window after the execution of batch file. <ref>[https://www.computerhope.com/pausehlp.htm MS-DOS pause command help]</ref><ref>[https://stackoverflow.com/questions/988403/how-to-prevent-auto-closing-of-console-after-the-execution-of-batch-file windows - How to prevent auto-closing of console after the execution of batch file. - Stack Overflow]</ref>


== Application: Run the PHP script automatically at a specified time ==
== Application: Run the PHP script automatically at a specified time ==

Navigation menu