Hello Everyone,
If you have a requirement that you want to execute a PHP script through CLI on windows, then here are few pointers to help you with that.
First we need WAMP on our system.
And then, we need to locate php.exe, which should be in WAMP's directory. Normally at
C:\wamp\bin\php\php5.4.16\php.exe
Now we can run a PHP script from anywhere on a windows system, we just need to run it with the path to the php.exe file.
Like, I open up my command prompt by going to Windows>Run>cmd
I created a simple PHP script like
test.php
<?php
echo 'hello';
?>
Now if I am in the same folder as test.php is then I can run command like
C:\wamp\bin\php\php5.4.16\php.exe test.php
I will get ' hello ' as the out out.
If I have my PHP script in some other directory then simply add the path to the file. Like
C:\wamp\bin\php\php5.4.16\php.exe C:\wamp\www\test.php
It will definitely give an output.
Thanx
Anshumaan Bakshi
No comments:
Post a Comment