Short Parameters
It returns an array containing command-line arguments. For example, to get the value of-a-b and-C, you can do this:
$arguments = getopt ("A:B:C:");
You can run the script in the following way (there are no spaces are not related, note the first example and the second example):
PHP test.php-a app-b bar-c carorphp Test.php-aapp-bbar-ccar
Print_r ($arguments) will return:
Array ( [a] + = App [b] = bar [c] = car)
Attention:
1. The colon is required
2. If no value is specified, it will not appear in the array
Or just the example:
PHP test.php-a App
Print_r ($arguments):
Array ( [a] + = app)
About Long parameters
Earlier than PHP 5.3, if you use a long parameter (--name=value or--name value), you will probably get the following error message:
PHP warning:getopt (): No support for long options in the This build in ...
Therefore, it is best to use short parameters if the PHP version is earlier than 5.3.
More articles on "PHP getopt functions"
Related information:
- Methods of sorting several arrays in php|php
- php| Full ASCII Code table
- Php|drupal Template Naming conventions
- php|php getopt function
- php|php the installation of MongoDB
- php|php asynchronous call to a background call for continuous disconnection/browser execution
- Php|php write and read serialized cookies
PHP getopt function Source Network, if there is infringement please inform, that is processing!
PHP function getopt Detailed