How to Execute PHP Scripts Using Command Line In Windows

How to execute php scripts using command line in windows, if you want to execute php scripts through windows command line, then that is simple and easy. Login to windows machine, Open command prompt from with in command prompt and navigate to php directory, there you can find php executable file. From that folder access php executable file then path to your php file. Then that php file will be executed through command line.

If you want to learn How to execute php scripts using command line in Linux.
First of all create a php file anywhere in your file system.

<?php
echo "testing";
echo "\n";
?>

From command prompt navigate to C:\wamp\bin\php\php5.3.13 this path using cd (change directory) command , if you are using wamp web server. In that folder you can find php.exe an executable file.

Next use this command

php.exe path-to-your-php-file

Now your code will be executed, without navigating to php directory in WAMP server, you can execute these scripts using php command php -v

If you can see php version info you can use this command instead of navigating to php directory and calling php.exe file. You can use this code.

php path-to-your-php-file

This article How to execute php scripts using command line in windows helped you, subscribe to newsletter and follow us on twitter and facebook.

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe