PHP Command line

WBOY
Release: 2016-07-25 08:48:35
Original
1294 people have browsed it
PHP command line to obtain parameters

Code source: http://www.haowei.me/archives/916.html
Code demonstration: 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


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!