PHP Command Line

Source: Internet
Author: User
PHP command line to get the parameters

Code Source: http://www.haowei.me/archives/916.html
Code Demo: Http://www.haowei.me/archives/916.html?osc
    1. [Hacker@broiler/]# php-r "echo \" php Command line.\ ";"
    2. PHP Command Line.
    3. [Hacker@broiler/]#
    4. [Hacker@broiler/]#
    5. [Hacker@broiler/]# Php-r "echo __file__;"
    6. Command Line Code
    7. [Hacker@broiler/]#
    8. [Hacker@broiler/]#
    9. [Hacker@broiler/]# php "test.php" 1 2 3 4
    10. Int (5)
    11. Array
    12. (
    13. [0] = test.php
    14. [1] = 1
    15. [2] = 2
    16. [3] = 3
    17. [4] = 4
    18. )
    19. [Hacker@broiler/]#
    20. [Hacker@broiler/]#
    21. [Hacker@broiler/]# Cat test.php
    22. Var_dump ($_server["ARGC"]);
    23. Print_r ($_server["argv"]);
    24. [Hacker@broiler/]#
    25. [Hacker@broiler/]#
Copy Code
  • 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.