$GLOBALS[“argv”] and $argv empty, $_SERVER[“argv”] just fine

posonty

New Member
I am fighting with a (perhaps) simple problem with PHP CLI running on Hostgator shared hosting. A simple code:\[code\]<?phpvar_dump($argv);var_dump($GLOBALS["argv"]);var_dump($_SERVER["argv"]);var_dump(ini_get("register_argv_argv"));?>\[/code\]When run on my local machine as well as several other instances of php as:\[code\]php test.php arg1\[/code\]Outputs correctly as predicted:\[code\]array ( 0 => 'test.php', 1 => 'arg1')array ( 0 => 'test.php', 1 => 'arg1')array ( 0 => 'test.php', 1 => 'arg1')1\[/code\]But run from cron on Hostgator shared hosting it outputs:\[code\]array ()NULLarray ( 0 => 'test.php', 1 => 'arg1')1\[/code\]The code I am fighting with is a legacy one and that relies heavily upon $GLOBALS["argv"] to parse command line parameters. I have no means to modify the whole codebase to rely on $_SERVER["argv"] instead.What might be the reason why all my instances of PHP fills all the arrays with commandline parameters, and the hosted php on Hostgator does not populate $GLOBALS["argv"] at all?I made a workaround to deal with this problem, but I hate when I don't know why something is happening :)Thanks for any ideas!
 
Top