Skip to content
PHP Logo

How can the PHP configuration setting 'register_globals' impact passing variables between scripts?

When the 'register_globals' setting is enabled in PHP, it automatically creates global variables for any user input, making it easier for variables to be overwritten or manipulated unintentionally. This can lead to security vulnerabilities and unpredictable behavior in scripts. To prevent this, it is recommended to disable the 'register_globals' setting in the PHP configuration.

php
// Disable register_globals in PHP configuration
// This can be done by setting register_globals = Off in php.ini file

// Alternatively, you can disable it at runtime using ini_set
ini_set('register_globals', 0);