How to override register_argc_argv in PHP?

2019-02-21 21:53发布

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?

2条回答
走好不送
2楼-- · 2019-02-21 22:25

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
查看更多
Anthone
3楼-- · 2019-02-21 22:36

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

php -d register_argc_argv=1 myscript.php
查看更多
登录 后发表回答