Command-line arguments are a common way to parameterize execution of programs. For example, php script.php uses script.php as an argument to the php program.
To experiment with command-line arguments, save this script and run it from the command line:
In PHP, the $argv array contains all command-line arguments, including the script name. The array_slice() function is used to create a new array without the script name.
Next, we’ll look at more advanced command-line processing with option parsing libraries in PHP.