Skip to main content

Running PHP by command line on WAMP

There are a few simple steps one can follow to run php scripts by command line.

Usually if you write "php" on the DOS prompt it will not recognize the command. In order to run php on command line in windows you have to do the following -
Step 1 : Go to your wamp directory:\wamp\bin\php\php5.x.x (directory depends on your version). Copy this path

Step 2 : Right click on My Computer and go to properties > Advanced > Environment Variables > System Variables . In that window select "path" click edit button. Go to the end of "Variable Value" and add a semi-colon ";" and after that paste the path copied. Click "Ok" and close.
Step 3 : Open a fresh command prompt . Type php. Now it should run.

Comments

  1. Thanks! I spent more time than I care to admit before finally finding you.
    jerryLee
    http://seointexas.com

    ReplyDelete
  2. Thank you for this post. The keywords that made it work for me was "fresh command prompt"... stupid me.

    ReplyDelete
  3. its not working for me . i done the same thing what u told . i am geting a error php not recognized .

    ReplyDelete
  4. Not working for me on Windows 7. Strangely if I install php separately in for example c:\php, then all is fine, but the WAMP server doesn't start successfully, which renders this workaround useless.

    ReplyDelete
  5. Thanks. Was searching for this on google

    ReplyDelete

Post a Comment

Popular posts from this blog

Title of the page

This is a PHP function to get the title of the page function getTitle($content) { $url_pattern="/<title>(.*?)<\/title>/ims"; preg_match($url_pattern,$content,$matches); return strip_tags($matches[1]); }

Ajax with Jquery

This time I wanted to write something for Jquery. Jquery is a very good Javascript library. It reduces much of your coding time. So here is how you do AJAX with Jquery Step 1 -: Download the latest version of jquery from here. This is Jquery 1.4 minified version. Step 2 -: $.get(url,'',function(data){ alert("Data from ajax is "+data); }); Done !!! Now I will explain it- 1.The "$" is nothing but a shorthand notation for jQuery. 2.Then comes "get" , this can be replaced with post as well, as this is the method by which the http request will be sent to the server. 3.Next is "url". This is the url of the page you are requesting. 4.After url I have the next parameter is left as '' . This parameter is just for adding the parameters (query strings) to the url. It is left to the programmer that he wants to use this parameter or not . You can club your query string in the Url also. 5.Finally we have a