📄 function.import-request-variables.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Import GET/POST/Cookie variables into the global scope</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="function.gettype.html">gettype</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.intval.html">intval</a></div> <div class="up"><a href="ref.var.html">Variable handling Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.import-request-variables" class="refentry"> <div class="refnamediv"> <h1 class="refname">import_request_variables</h1> <p class="verinfo">(PHP 4 >= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">import_request_variables</span> — <span class="dc-title">Import GET/POST/Cookie variables into the global scope</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>import_request_variables</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$types</tt></span> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$prefix</tt></span> ] )</div> <p class="para rdfs-comment"> Imports GET/POST/Cookie variables into the global scope. It is useful if you disabled <a href="ini.core.html#ini.register-globals" class="link">register_globals</a>, but would like to see some variables in the global scope. </p> <p class="para"> If you're interested in importing other variables into the global scope, such as SERVER, consider using <a href="function.extract.html" class="function">extract()</a>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">types</tt></i></span> <dd> <p class="para"> Using the <i><tt class="parameter">types</tt></i> parameter, you can specify which request variables to import. You can use 'G', 'P' and 'C' characters respectively for GET, POST and Cookie. These characters are not case sensitive, so you can also use any combination of 'g', 'p' and 'c'. POST includes the POST uploaded file information. </p> <blockquote><p><b class="note">Note</b>: Note that the order of the letters matters, as when using "gp", the POST variables will overwrite GET variables with the same name. Any other letters than GPC are discarded. <br /> </p></blockquote> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">prefix</tt></i></span> <dd> <p class="para"> Variable name prefix, prepended before all variable's name imported into the global scope. So if you have a GET value named "userid", and provide a prefix "pref_", then you'll get a global variable named <var class="varname">$pref_userid</var>. </p> <blockquote><p><b class="note">Note</b>: Although the <i><tt class="parameter">prefix</tt></i> parameter is optional, you will get an <a href="errorfunc.constants.html#errorfunc.constants.errorlevels.e-notice" class="link">E_NOTICE</a> level error if you specify no prefix, or specify an empty string as a prefix. This is a possible security hazard. Notice level errors are not displayed using the default <a href="errorfunc.configuration.html#ini.error-reporting" class="link">error reporting</a> level. <br /> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>import_request_variables()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// This will import GET and POST vars<br />// with an "rvar_" prefix<br /></span><span style="color: #0000BB">import_request_variables</span><span style="color: #007700">(</span><span style="color: #DD0000">"gp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"rvar_"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$rvar_foo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><var class="varname"><a href="reserved.variables.request.html" class="classname">$_REQUEST</a></var></li> <li class="member"><a href="ini.core.html#ini.register-globals" class="link">register_globals</a></li> <li class="member"><a href="language.variables.predefined.html" class="link">Predefined Variables</a></li> <li class="member"><a href="function.extract.html" class="function" rel="rdfs-seeAlso">extract()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gettype.html">gettype</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.intval.html">intval</a></div> <div class="up"><a href="ref.var.html">Variable handling Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -