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 can a PHP program prompt for the coefficients of a quadratic polynomial?ComputerScienceOne · Computing Quadratic Roots
- How can you create and use arrays of strings in PHP?ComputerScienceOne · Comparisons
- How are command line arguments accessed and converted in Java?ComputerScienceOne · The javamain() Method
- How can PHP read and clean user input from standard input?ComputerScienceOne · Converting Units
- How does PHP perform basic input and output?ComputerScienceOne · Basic I/O
- What are the main characteristics of PHP as a programming language?ComputerScienceOne · Basic Syntax Rules
- How do PHP tags identify code that should be interpreted as PHP?ComputerScienceOne · Libraries