As with the title of the article, there will be more and more discussions about PHP4.2 and later versions and register_globals. If your PHP program works normally before, but an error occurs after it is upgraded to PHP4.2, read the following carefully: In the past, in your PHP, there may be a table like below: and SyntaxHighlighter. all
As with the title of the article, there will be more and more discussions about PHP4.2 and later versions and register_globals. If your PHP program works normally before, but an error occurs after it is upgraded to PHP4.2, read the following carefully: In the past, in your PHP, there may be a table like the following, you can access your variables as easily as below: A problem occurs when you upgrade PHP to PHP4.2. during installation, php sets register_globals to off by default. this register_globals is PHP. in ini, you can set whether to directly use the $ variable parameter in the preceding example. The value of register_globals is on by default until PHP4.2 or earlier. that is to say, you can directly output the variable. However, in versions later than PHP4.2, to prevent potential insecure code overflow, the PHP development team has set register_globals to off by default. This means that the above code is no longer output. [Translator's note: Using a series of PHP functions, you can also directly access the variable when register_globals is off.] In fact, when using the above table, we can access the input values in several ways. Because we use the POST method to submit data, we can use the _ POST array, for example: Alternatively, if the preceding table is submitted using the GET method, we can use the _ GET array: If you do not know whether you use the POST or GET method to submit data for some reason, you can use the _ REQUEST array, for example: The array variable names of cookies and sessions are _ COOKIE and _ SESSION. you can access the variable values in the same way. There are also _ SERVER, _ FILES, _ ENV and GLOBALS arrays, which are global variables of PHP and can be used anywhere in PHP, including in functions and classes. The following code can also work properly: $ Value) echo "$ _ POST [$ key] => $ value
";}?> You can directly use this global variable without using the global $ _ POST statement in the function. For more information, see The PHP online manual: http://www.php.net/manual/en/language.variables.predefined.php