Execute php script in a bat file: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 1: Line 1:
How to execute php script in a bat file
How to execute php script in a batch (bat) file


== Case 1: Execute the PHP code directly ==
== Case 1: Execute the PHP code directly ==
Line 10: Line 10:
</pre>
</pre>


: [[Image:Owl icon.jpg]] If you do not known where is the path of php, you may open the DOS window ({{kbd | key=<nowiki>cmd</nowiki>}}) and key in {{kbd | key=<nowiki>where php</nowiki>}} to obtain the path of php.
: [[Image:Owl icon.jpg]] If you do not know where PHP installed, you may open the DOS window ({{kbd | key=<nowiki>cmd</nowiki>}}) and key in {{kbd | key=<nowiki>where php</nowiki>}} to find the path.


== Case 2: Execute the PHP script file without passing parameters ==
== Case 2: Execute the PHP script file without passing parameters ==
Line 31: Line 31:




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>


== Example of bat file ==
== Example of BAT file for Windows ==
Condition 1: The DOS window was closed automatically when PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1.
Condition 1: The DOS window was closed automatically when PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1.
<pre>
<pre>
Line 52: Line 52:
</pre>
</pre>


== Example of bash file ==
== Example of BASH file for Linux ==
PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1<ref>[https://stackoverflow.com/questions/6827837/accessing-errorlevel-from-bash-script cmd - accessing ERRORLEVEL from bash script - Stack Overflow]</ref><ref>[https://www.tldp.org/LDP/abs/html/comparison-ops.html Other Comparison Operators]</ref><ref>[https://unix.stackexchange.com/questions/293940/bash-how-can-i-make-press-any-key-to-continue Bash - How can I make "Press any key to continue" - Unix & Linux Stack Exchange]</ref>.
PHP script which implemented [http://php.net/manual/en/function.exit.php exit()] and return error code 1<ref>[https://stackoverflow.com/questions/6827837/accessing-errorlevel-from-bash-script cmd - accessing ERRORLEVEL from bash script - Stack Overflow]</ref><ref>[https://www.tldp.org/LDP/abs/html/comparison-ops.html Other Comparison Operators]</ref><ref>[https://unix.stackexchange.com/questions/293940/bash-how-can-i-make-press-any-key-to-continue Bash - How can I make "Press any key to continue" - Unix & Linux Stack Exchange]</ref>.
<pre>
<pre>
Anonymous user

Navigation menu