Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override register_argc_argv in PHP?

I'm using a shared host (fasthostingdirect) and for some reason they have this flag turned off by default. This means I'm unable to access PHP command line parameters... unless I use the -n (= --no-php-info) flag after php.exe.

Have tried ini_set('register_argc_argv', 1) in my php file but it has no effect. Am guessing this is due to the clamped down nature of the hosting provider, however they don't stop the -n option - not sure of the other implications of using this though. Does anyone have any better suggestions?

like image 577
Steve Chambers Avatar asked Jul 12 '12 20:07

Steve Chambers


People also ask

How do I pass a command line argument in PHP?

To pass command line arguments to the script, we simply put them right after the script name like so... Note that the 0th argument is the name of the PHP script that is run. The rest of the array are the values passed in on the command line. The values are accessed via the $argv array.

What is $argv in PHP?

$argv — Array of arguments passed to script.

What is argc in PHP?

$argc — The number of arguments passed to script.


1 Answers

No need to create a whole new ini file, just use the -d flag

php -d register_argc_argv=1 myscript.php
like image 189
IanS Avatar answered Sep 23 '22 12:09

IanS