Skip to content

Commit

Permalink
Added cli with php
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-sanjjeev committed Nov 13, 2024
1 parent a70dd14 commit 285b278
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions docs/cli-with-php.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 285b278

Please sign in to comment.