How to Execute PHP Files on Command Line in Windows

please click here for more wordpress cource

To execute PHP files on the command line in Windows, follow these steps:

  1. Install PHP: If you haven’t installed PHP on your system yet, download and install it from the official website. Make sure to add PHP to your system’s PATH environment variable so that you can run it from the command line.
  2. Open the command prompt: Press the Windows key + R to open the Run dialog box. Type “cmd” and press Enter to open the command prompt.
  3. Navigate to the directory containing the PHP file: Use the “cd” command to change the current directory to the one containing the PHP file. For example, if your PHP file is located in the “C:\php” directory, type “cd C:\php” and press Enter.
  4. Execute the PHP file: To execute the PHP file, type “php filename.php” and press Enter. Replace “filename.php” with the name of your PHP file.
  5. Check the output: The output of the PHP file will be displayed in the command prompt window. You can also redirect the output to a file using the “>” operator. For example, to save the output to a file named “output.txt”, type “php filename.php > output.txt” and press Enter.

That’s it! You have successfully executed a PHP file on the command line in Windows.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *