8

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?

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
  • just move hosts. Trying to override their settings is a great way to get kicked off. –  Jul 12 '12 at 20:21

2 Answers2

8

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

php -d register_argc_argv=1 myscript.php
IanS
  • 1,459
  • 1
  • 18
  • 23
  • WOOO this worked!! I was trying to run a php file from crontab and was not able to get url parameters, but this worked! thanks so much. – William Howley Apr 24 '20 at 16:00
6

The ini_set('register_argc_argv', 1) does not work because by the time the code is executed, they have already been registered (or not).

It seems you are able to run php directly, so copy your own php.ini file and pass it:

php -c yourphp.ini