Skip to content

How to disable register_argc_argv in PHP

The PHP setting register_argc_argv determines whether the $argc and $argv variables are automatically registered in the global scope when running PHP scripts. These variables contain command-line arguments, which are typically useful for CLI scripts, but can pose a security risk in web applications with improper variable handling.

To disable register_argc_argv for all apps using a particular PHP version, SSH into your server as root and run the following command.

Terminal window
echo "register_argc_argv = 0" > /etc/php8.4-sp/conf.d/disable_register_argc_argv.ini

Next, restart PHP.

Terminal window
sudo service php8.4-fpm-sp restart

Finally, verify the setting is disabled.

The above steps should be repeated for each version of PHP where you want to disable register_argc_argv.