To Execute PHP File From Command Line, we can use 2 methods to execute the PHP file code by PHP command,
- By using XAMPP Shell or Command line.
- Inbuilt command line of Windows OS.
Note: If you want to use inbuilt command line interface of Windows OS, you have install PHP manually from PHP official package. Here is the complete step by step process to install PHP How To Install PHP In Windows 10.
Execute PHP File Using XAMPP Shell
Steps to Execute PHP Code Using XAMPP Command Line
- If you do not have the XAMPP package, install it from the official site Download XAMPP (apachefriends.org)
- Open the XAMPP control panel by clicking on the icon.
- Click on the Shell option in the sidebar of the control panel.
- It will open the command line then you go for the file path by using the CD command.
- At last, run the PHP file by using below PHP command.
Execute PHP File Using Inbuilt Command Line
Here are some major steps to execute PHP code using the Windows command line interface,
- Install PHP by official PHP package How To Install PHP In Windows 10.
- Set the path of PHP in the environment variable at the time of PHP installation.
- Open the CMD interface and run the below command.
Here is the complete step-by-step process of How to run the PHP file from the command line interface of Windows and XAMPP Shell.
If you get something error in implementation please comment below.
- Increase PHPMyAdmin Import Size Ubuntu and XAMPP
- Send Mail From Localhost in PHP Using XAMPP
- How to Get Input Value From User in PHP?
- isset vs empty vs is_null in PHP With Example