I am struggling with a (possibly) simple problem with the PHP CLI running on Hostgator hosting. Simple code:
<?php var_dump($argv); var_dump($GLOBALS["argv"]); var_dump($_SERVER["argv"]); var_dump(ini_get("register_argv_argv")); ?>
When launched on my local computer, as well as in several other php instances:
php test.php arg1
It is displayed correctly, as predicted:
array ( 0 => 'test.php', 1 => 'arg1' ) array ( 0 => 'test.php', 1 => 'arg1' ) array ( 0 => 'test.php', 1 => 'arg1' ) 1
But run cron on the Hostgator hosting, which it issues:
array ( ) NULL array ( 0 => 'test.php', 1 => 'arg1' ) 1
The code I'm struggling with is deprecated, and it relies heavily on $ GLOBALS ["argv"] to parse command-line options. I donβt have the means to change the entire codebase to use $ _SERVER ["argv"] instead.
What could be the reason that all my PHP instances fill all arrays with command line parameters, and hosted php hostgator doesn't fill $ GLOBALS ["argv"] at all?
I made a workaround to solve this problem, but I hate it when I donβt know why something is happening :)
Thanks for any ideas!
source share