Home  >  Article  >  Backend Development  >  Using table data in PHP4.2 and later versions_PHP Tutorial

Using table data in PHP4.2 and later versions_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:29:22878browse

As the title of the article suggests, there will be more and more discussions about the release of PHP 4.2 and later versions and register_globals. If your PHP program worked normally before, but an error occurred after upgrading to PHP4.2, please read the following carefully: In the past, in your PHP, there may have been a table like the following: Moreover, you can access it as simply as the following Your variables: Something went wrong when upgrading to PHP 4.2 - during installation, PHP set register_globals=off by default. This register_globals is set in php.ini to allow direct use of variables in the example above. For the parameters of $variable, until versions before PHP 4.2, register_globals defaulted to on, which means that variables can be output directly. However, in PHP 4.2 and later versions, in order to prevent potentially unsafe code from overflowing, the PHP development team has set register_globals to off by default. This means that the above code no longer produces output. [Translator's Note: Through a series of PHP functions, you can also directly access variables when register_globals=off. ] Actually, when using the above form, we can access the entered values ​​in several ways. Because we use the POST method to submit data, we can use the _POST array, for example: Or, if the above form is submitted through the GET method, we can use the _GET array: If you are for some reason I don’t know whether you used POST or GET to submit data. You can use the _REQUEST array for all, for example: The corresponding array variable names for cookies and sessions are _COOKIE and _SESSION, which can be accessed through the same method. The value of the variable. There are also _SERVER, _FILES, _ENV and GLOBALS arrays. These are global variables of PHP and can be used anywhere in PHP, including in functions and classes. The following code will also work fine: $value ) echo "$_POST[$key] => $value


"; } ?> You don't need to use the statement global $_POST; in the function, just You can use this global variable directly. For more information, please refer to the PHP online manual: http://www.php.net/manual/en/language.variables.predefined.php

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531693.htmlTechArticleJust like the title of the article, there will be more and more discussions about the publication of PHP4.2 and later versions and register_globals. If your PHP program worked normally before, but after upgrading to PHP4.2...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn