Concept
How does a PHP script use entry points and command line arguments?
ComputerScienceOne / Entry Point & Command Line Arguments
"37.2.5. Entry Point & Command Line Arguments Every PHP script begins executing at the top of the script file and proceed in a linear, sequential manner top-to-bottom. In addition, you can provide a PHP script with inputs when you run it from the command line. These command line arguments are stored in two variables, $argc and $argv . The first variable, $argc is an integer that indicates the number of arguments provided including the name of the script file being executed. The second, $argv is an array (see Section 42) of strings consisting of the command line arguments. To access them, you can index them starting at zero, the first being $argv[0] , the second $argv[1] , the last one would be $argv[$argc-1] . The first one is always the name of the script file being run. The remaining are the command line arguments provided by the user when the script is executed. We’ll see several examples later."
Related Ideas
- How do argc and argv provide and convert command-line arguments?ComputerScienceOne · The cmain() Function
- How does PHP perform basic input and output?ComputerScienceOne · Basic I/O
- What environment is needed to run a basic PHP program?ComputerScienceOne · Getting Started: Hello World
- What are the main characteristics of PHP as a programming language?ComputerScienceOne · Basic Syntax Rules
- How does PHP handle file input and output?ComputerScienceOne · Opening Files