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?
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.
$argv — Array of arguments passed to script.
$argc — The number of arguments passed to script.
No need to create a whole new ini file, just use the -d
flag
php -d register_argc_argv=1 myscript.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With