PHP5コマンドライン引数を取得

[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
<?php

var_dump($_SERVER[“argc"]);
print_r($_SERVER[“argv"]);

[hacker@broiler /]#
[hacker@broiler /]#

Source

Posted by arkgame