Using command line arguments
The args parameter of the main() method stores the command line arguments passed to the program.
Command line arguments are information provided after the program name on the command line during execution.
These arguments are stored as strings in a String array passed to main().
The following example demonstrates how to display all command-line arguments provided to the program.
Output below:
There are 3 command-line arguments.
They are:
arg[0]: one
arg[1]: two
arg[2]: three
Command line arguments are stored in an array, with the first argument at index 0, the second at index 1, and so on.
The following example illustrates how to use command-line arguments to receive a person's name.
The program searches for this name in a two-dimensional array of strings.
If the name is found, the program will display the corresponding phone number.
The above is the detailed content of Using command line arguments. For more information, please follow other related articles on the PHP Chinese website!