<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Import GET/POST/Cookie variables into the global scope</title> </head> <body><div class="manualnavbar" 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.1.0, PHP 5 < 5.4.0)</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" id="refsect1-function.import-request-variables-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>import_request_variables</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$types</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$prefix</code></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 <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var>, consider using <span class="function"><a href="function.extract.html" class="function">extract()</a></span>. </p> <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function has been <em class="emphasis">DEPRECATED</em> as of PHP 5.3.0 and <em class="emphasis">REMOVED</em> as of PHP 5.4.0.</p></div> </div> <div class="refsect1 parameters" id="refsect1-function.import-request-variables-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">types</code></em></span> <dd> <p class="para"> Using the <em><code class="parameter">types</code></em> 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 class="note"><p><strong class="note">Note</strong>: <p class="para"> Note that the order of the letters matters, as when using "<em>GP</em>", the POST variables will overwrite GET variables with the same name. Any other letters than GPC are discarded. </p> </p></blockquote> </dd> </dt> <dt> <span class="term"><em><code class="parameter">prefix</code></em></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 "<em>userid</em>", and provide a prefix "<em>pref_</em>", then you'll get a global variable named <var class="varname"><var class="varname">$pref_userid</var></var>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Although the <em><code class="parameter">prefix</code></em> parameter is optional, you will get an <a href="" class="link"><strong><code>E_NOTICE</code></strong></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. </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.import-request-variables-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.import-request-variables-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5254"> <p><strong>Example #1 <span class="function"><strong>import_request_variables()</strong></span> example</strong></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" id="refsect1-function.import-request-variables-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><var class="varname"><var class="varname"><a href="reserved.variables.request.html" class="classname">$_REQUEST</a></var></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"> <span class="function"><a href="function.extract.html" class="function" rel="rdfs-seeAlso">extract()</a> - Import variables into the current symbol table from an array</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" 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>