Skip to content
PHP Logo

What considerations should be made when programming with register globals on/off in PHP?

When programming with register_globals set to on in PHP, it poses a security risk as it allows external variables to overwrite the values of your script's variables. To mitigate this risk, it is recommended to turn off register_globals in the PHP configuration or use superglobal arrays like $_GET, $_POST, and $_REQUEST to access variables.

php
// Set register_globals to off in php.ini or .htaccess file
// or use superglobal arrays to access variables

$myVar = $_GET['myVar'];