PHP getopt functions

Source: Internet
Author: User
Tags php source code
Introduction: This is the PHP getopt function of the detailed page, introduced and PHP, related knowledge, skills, experience, and some PHP source code and so on.

class= ' pingjiaf ' frameborder= ' 0 ' src= ' http://biancheng.dnbcw.info/pingjia.php?id=336873 ' scrolling= ' no ' > 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"

Love EE focus on Java Michael Jackson Video station JSON online tool

Http://biancheng.dnbcw.info/php/336873.html Pageno:9
  • 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.