---
title: "How can I execute a PHP script using command line?"  
description: "How can I execute a PHP script using command line?"  
author: "Amit Singh"  
published: 2011-04-29  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/809/how-can-i-execute-a-php-script-using-command-line  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# How can I execute a PHP script using command line?

Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. \
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

## Answers

### Answer by Amit Singh

Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. \
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.


---

Original Source: https://www.mindstick.com/interview/809/how-can-i-execute-a-php-script-using-command-line

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
