Use table data in versions later than PHP4.2

Source: Internet
Author: User
Tags php online
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.