tutorial.oldcode.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 70 行
HTML
70 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Using old code with new versions of PHP</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="tutorial.forms.html">Dealing with Forms</a></div> <div class="next" style="text-align: right; float: right;"><a href="tutorial.whatsnext.html">What's next?</a></div> <div class="up"><a href="tutorial.html">A simple tutorial</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="tutorial.oldcode" class="section"> <div class="info"><h1 class="title">Using old code with new versions of PHP</h1></div> <p class="para"> Now that PHP has grown to be a popular scripting language, there are a lot of public repositories and libraries containing code you can reuse. The PHP developers have largely tried to preserve backwards compatibility, so a script written for an older version will run (ideally) without changes in a newer version of PHP. In practice, some changes will usually be needed. </p> <p class="para"> Two of the most important recent changes that affect old code are: <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> The deprecation of the old <var class="varname">$HTTP_*_VARS</var> arrays (which need to be indicated as global when used inside a function or method). The following <a href="language.variables.superglobals.html" class="link">superglobal arrays</a> were introduced in PHP <a href="http://www.php.net/releases/4_1_0.php" class="link external">» 4.1.0</a>. They are: <var class="varname"><a href="reserved.variables.get.html" class="classname">$_GET</a></var>, <var class="varname"><a href="reserved.variables.post.html" class="classname">$_POST</a></var>, <var class="varname"><a href="reserved.variables.cookies.html" class="classname">$_COOKIE</a></var>, <var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var>, <var class="varname"><a href="reserved.variables.files.html" class="classname">$_FILES</a></var>, <var class="varname"><a href="reserved.variables.environment.html" class="classname">$_ENV</a></var>, <var class="varname"><a href="reserved.variables.request.html" class="classname">$_REQUEST</a></var>, and <var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var>. The older <var class="varname">$HTTP_*_VARS</var> arrays, such as <var class="varname">$HTTP_POST_VARS</var>, also exist. As of PHP 5.0.0, the long PHP <a href="language.variables.predefined.html" class="link">predefined variable</a>arrays may be disabled with the <a href="ini.core.html#ini.register-long-arrays" class="link">register_long_arrays</a>directive. </span> </li> <li class="listitem"> <span class="simpara"> External variables are no longer registered in the global scope by default. In other words, as of PHP <a href="http://www.php.net/releases/4_2_0.php" class="link external">» 4.2.0</a> the PHP directive <a href="ini.core.html#ini.register-globals" class="link">register_globals</a> is <em class="emphasis">off</em> by default in <var class="filename">php.ini</var>. The preferred method of accessing these values is via the superglobal arrays mentioned above. Older scripts, books, and tutorials may rely on this directive being on. If it were on, for example, one could use <var class="varname">$id</var> from the URL <i>http://www.example.com/foo.php?id=42</i>. Whether on or off, <var class="varname"><a href="reserved.variables.get.html" class="classname">$_GET['id']</a></var> is available. </span> </li> </ul> For more details on these changes, see the section on <a href="language.variables.predefined.html" class="link">predefined variables</a> and links therein. </p> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="tutorial.forms.html">Dealing with Forms</a></div> <div class="next" style="text-align: right; float: right;"><a href="tutorial.whatsnext.html">What's next?</a></div> <div class="up"><a href="tutorial.html">A simple tutorial</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?