How can i execute PHP File using Command Line?

devquora
devquora

Posted On: Feb 22, 2018

 

It is easy and simple to execute PHP scripts from the windows command prompt. You just follow the below steps:

1. Open the command prompt. Click on Start button->Command Prompt.

2. In the Command Prompt, write the full path to the PHP executable(php.exe) which is followed by the full path of a script that you want to execute. You must add space in between each component. It means to navigate the command to your script location.

For example,

let you have placed PHP in C:\PHP, and your script is in C:\PHP\sample-php-script.php,

then your command line will be:

C:\PHP\php.exe C:\PHP\sample-php-script.php

3. Press the enter key and your script will execute.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    PHP Interview Questions

    What is T_PAAMAYIM_NEKUDOTAYIM in PHP?

    T_PAAMAYIM_NEKUDOTAYIM is scope resolution operator used as :: (double colon) .Basically, it used to call static methods/variables of a Class...

    PHP Interview Questions

    What is the difference between == and === operator in PHP ?

    In PHP == is equal operator and returns TRUE if $a is equal to $b after type juggling and === is Identical operator and return TRUE if $a is equal to $b, and they are of the same data type...