diff --git a/README.md b/README.md index 6748812..00c47fe 100644 --- a/README.md +++ b/README.md @@ -180,8 +180,9 @@ This repository contains PHP topics and their notes to learn from beginner level - [Generating XML](./docs/xml-and-json.md#-generating-xml), - [Generating JSON](./docs/xml-and-json.md#-generating-json), - [Key Points](./docs/xml-and-json.md#-key-points) -3. CLI with PHP: - - Executing PHP scripts from the command line +3. [CLI with PHP:](./docs/cli-with-php.md) + - [Executing PHP Script in Command Line](./docs/cli-with-php.md#-executing-php-script-in-command-line), + - [Accepting Command Line Arguments](./docs/cli-with-php.md#-accepting-command-line-arguments) 4. Debugging and Profiling: - Advanced debugging techniques - Performance optimization diff --git a/docs/cli-with-php.md b/docs/cli-with-php.md new file mode 100644 index 0000000..7adeae7 --- /dev/null +++ b/docs/cli-with-php.md @@ -0,0 +1,33 @@ +## ➲ CLI With PHP: +PHP offers to execute script through command line. + +### ☴ Overview: +1. [Executing PHP Script in Command Line](#-executing-php-script-in-command-line), +2. [Accepting Command Line Arguments](#-accepting-command-line-arguments) + +### ✦ Executing PHP Script in Command Line: +To execute PHP script in command line, use `php scriptname.php` in command line. + +```bash +php test.php +``` + +### ✦ Accepting Command Line Arguments: +To PHP accepts command line arguments and deliver through the variable `argv`. + +```bash +php test.php arg1 arg2 arg3 +``` + +```php +foreach ($argv as $arg) { + echo $arg . "\n"; +} +``` + +--- +[⇪ To Top](#-cli-with-php) + +[❮ Previous Topic](./xml-and-json.md)   [Next Topic ❯](./debugging-and-profiling.md) + +[⌂ Goto Home Page](../README.md) \ No newline at end of file