PHPCommandline
时间:2021-07-01 10:21:17
帮助过:33人阅读
PHP 命令行获取传参
代码出处:http://www.haowei.me/archives/916.html 代码演示:http://www.haowei.me/archives/916.html?osc
- [hacker@broiler /]# php -r "echo \"PHP Command Line.\";"
- PHP Command Line.
- [hacker@broiler /]#
- [hacker@broiler /]#
- [hacker@broiler /]# php -r "echo __FILE__;"
- Command line code
- [hacker@broiler /]#
- [hacker@broiler /]#
- [hacker@broiler /]# php "test.php" 1 2 3 4
- int(5)
- Array
- (
- [0] => test.php
- [1] => 1
- [2] => 2
- [3] => 3
- [4] => 4
- )
- [hacker@broiler /]#
- [hacker@broiler /]#
- [hacker@broiler /]# cat test.php
- var_dump($_SERVER["argc"]);
- print_r($_SERVER["argv"]);
- [hacker@broiler /]#
- [hacker@broiler /]#
|