15,024
edits
No edit summary |
|||
| Line 1: | Line 1: | ||
How to execute php script in a bat file | How to execute php script in a bat file | ||
== Case 1: Execute the PHP script without passing parameters == | == Case 1: Execute the PHP code directly == | ||
# Enter {{kbd | key=cmd}} to open Windows Command Line | |||
# Enter the following command: | |||
<pre> | |||
c:\path\to\php.exe -r "echo 'Hello';" | |||
</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. | |||
== Case 2: Execute the PHP script file without passing parameters == | |||
<pre> | <pre> | ||
c:\path\to\php.exe -f "c:\path\to\php_script.php" | c:\path\to\php.exe -f "c:\path\to\php_script.php" | ||
| Line 10: | Line 21: | ||
</pre> | </pre> | ||
== Case 3: Execute the PHP script file passing parameters == | |||
== Case | |||
<pre> | <pre> | ||
c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1 | c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1 | ||