When executing PHP from the command line I've been using the $argv variable to get access to the arguments. Unfortunately this doesn't give you access to the actual command executed but instead something already parsed, in part, by the shell or PHP (I don't know which). Whatever it is you end up with some kind of bastardized implementation that does things incorrectly:
Code: Select all
$ echo '#!/usr/bin/php
> <?php
> print_r($argv);' > test.php
$ chmod +x test.php
$ ./test.php -
Array
(
[0] => ./test.php
[1] => -
)
$ ./test.php \-
Array
(
[0] => ./test.php
[1] => -
)
$ # no discernible difference despite the escape
$ foo='monkey love'
$ ./test.php $foo
Array
(
[0] => ./test.php
[1] => monkey
[2] => love
)
# "monkey love" should be combined in element 1