PHP function getopt Detailed

Source: Internet
Author: User
Tags php write

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.