<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_52050"> PHP 命令行获取传参<br><br>代码出处:http://www.haowei.me/archives/916.html<br>代码演示:http://www.haowei.me/archives/916.html?osc <div class="blockcode"> <div id="code_eHn"><ol> <li>[hacker@broiler /]# php -r "echo \"PHP Command Line.\";"</li> <li>PHP Command Line.</li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# php -r "echo __FILE__;"</li> <li>Command line code</li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# php "test.php" 1 2 3 4</li> <li>int(5)</li> <li>Array</li> <li>(</li> <li> [0] => test.php</li> <li> [1] => 1</li> <li> [2] => 2</li> <li> [3] => 3</li> <li> [4] => 4</li> <li>)</li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# cat test.php</li> <li><?php <li></li> <li>var_dump($_SERVER["argc"]);</li> <li>print_r($_SERVER["argv"]);</li> <li> <li>[hacker@broiler /]# </li> <li>[hacker@broiler /]# </li> </ol></div> <em onclick="copycode($('code_eHn'));">复制代码</em> </div> </td></tr></table> <div id="comment_52050" class="cm"> </div> <div id="post_rate_div_52050"></div> <br><br>