Source of: /manual/en/function.import-request-variables.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.var.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.import-request-variables.php',
1 => 'import_request_variables',
),
'up' =>
array (
0 => 'ref.var.php',
1 => 'Variable handling Functions',
),
'prev' =>
array (
0 => 'function.gettype.php',
1 => 'gettype',
),
'next' =>
array (
0 => 'function.intval.php',
1 => 'intval',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<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)</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>
<a name="function.import-request-variables.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">bool</span> <span class="methodname"><b>import_request_variables</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.php#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"><a href="reserved.variables.server.php" class="classname">$_SERVER</a></var>, consider using <a href="function.extract.php" class="function">extract()</a>.
</p>
</div>
<a name="function.import-request-variables.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">types</tt></i>
</span>
</dt><dd class="listitem">
<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
"<i>GP</i>", the
POST variables will overwrite GET variables with the same name. Any
other letters than GPC are discarded.
<br />
</p></blockquote>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">prefix</tt></i>
</span>
</dt><dd class="listitem">
<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
"<i>userid</i>", and provide a prefix
"<i>pref_</i>", 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.php#errorfunc.constants.errorlevels.e-notice" class="link"><b><tt class="constant">E_NOTICE</tt></b></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.php#ini.error-reporting" class="link">error reporting</a> level.
<br />
</p></blockquote>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.import-request-variables.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
</p>
</div>
<a name="function.import-request-variables.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 <b>import_request_variables()</b> example</b></p>
<div class="example-contents programlisting">
<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>
</p>
</div>
<a name="function.import-request-variables.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><var class="varname"><a href="reserved.variables.request.php" class="classname">$_REQUEST</a></var></li>
<li class="member"><a href="ini.core.php#ini.register-globals" class="link">register_globals</a></li>
<li class="member"><a href="language.variables.predefined.php" class="link">Predefined Variables</a></li>
<li class="member"><a href="function.extract.php" class="function" rel="rdfs-seeAlso">extract()</a> - Import variables into the current symbol table from an array</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>