Execute php script in a bat file

From LemonWiki共筆
Revision as of 10:30, 1 March 2018 by Planetoid (talk | contribs) (Created page with "How to execute php script in a bat file == Case 1: execute the php script without passing parameters == <pre> c:\path\to\php.exe -f "c:\path\to\php_script.php" or c:\path\t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

How to execute php script in a bat file

Case 1: execute the php script without passing parameters

c:\path\to\php.exe -f "c:\path\to\php_script.php"

or

c:\path\to\php.exe "c:\path\to\php_script.php"

Case 2: execute the php script passing parameters

c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1

or

c:\path\to\php.exe "c:\path\to\php_script.php" -var1=value1


Options "-f <file> Parse and execute <file>."[1]

Troubleshootings

Error message[2]: Could not open input file

The code caused the error message:

c:\path\to\php.exe -f "c:\path\to\php_script.php" -var1=value1

After:

c:\path\to\php.exe -f "c:\path\to\php_script.php" -- -var1=value1

or

c:\path\to\php.exe "c:\path\to\php_script.php" -var1=value1


References

Related articles