564 Part IV: Using PHP for Sysadmin Tasks (Web space)
564 Part IV: Using PHP for Sysadmin Tasks Listing 16-3: arg.php #!/usr/bin/php -q When this script is run as follows: ./args.php -h -k -x 100 it prints the following: Array ( [0] => ./arg.php [1] => -h [2] => -k [3] => -x [4] => 100 ) The $argv array is created by PHP, which stores all the command-line arguments as shown in the preceding output. However, it is not the most efficient way to deal with command arguments. Listing 16-4 shows a script called cmd_options.php, which uses the Console/Getopt.php class from the PEAR package. Listing 16-4: cmd_options.php #!/usr/bin/php -q