To Execute PHP File From Command Line, we can use 2 methods to execute 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.
In This Article
Execute PHP File Using XAMPP Shell
Steps to Execute PHP Code Using XAMPP Command Line
- If you do not have XAMPP package, install from official site Download XAMPP (apachefriends.org)
- Open XAMPP control panel by clicking on the icon.
- Click on Shell option in sidebar of control panel.
- It will open the command line then you go for file path by using 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 environment variable at the time PHP installation.
- Open 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