Is PHP $argv limited to 9 paramers on Windows?

Viewed 492

Running the following script in PHP 5.5.4 CLI on Win7 32bit

php -r "print_r($argv);" 1 2 3 4 5 6 7 8 9 10 11 12 13 14

I can see that only 8 arguments are actually parsed:

Array
(
    [0] => -
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
    [6] => 6
    [7] => 7
)

Does Windows or PHP limit the number of command line args to 8/ total 9?

Update:

Works as expected on same PC with PHP 5.5.7 -> so at least on Win7 this is a PHP-specific problem.

The behaviour changes depending on if the script is run from the php folder or if php is found via path. A procmon trace seems to indicate that the problem is with Windows as- even before the PHP.exe image is being loaded- a different number of parameters is passed:

php.exe Process Start       SUCCESS Parent PID: 9088, Command line: "\Program Files\php\php"  -r "print_r($argv);" 1 2 3 4 5 6 7, Current directory: C:\
php.exe Process Start       SUCCESS Parent PID: 9088, Command line: "\program files\php\php"  -r "print_r($argv);" 1 2 3 4 5 6 7 8 9 10 11 12 13 14, Current directory: C:\
php.exe Process Start       SUCCESS Parent PID: 9088, Command line: php  -r "print_r($argv);" 1 2 3 4 5 6 7 8 9 10 11 12 13 14, Current directory: C:\Program Files\php\

All parameters only seem to be available if PHP is NOT taken from the path.

1 Answers
Related