downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

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 &gt;= 4.1.0, PHP 5)</p><p class="refpurpose"><span class="refname">import_request_variables</span> &mdash; <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&#039;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 &#039;G&#039;, &#039;P&#039; and &#039;C&#039;
       characters respectively for GET, POST and Cookie. These characters are
       not case sensitive, so you can also use any combination of &#039;g&#039;, &#039;p&#039;
       and &#039;c&#039;. 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
        &quot;<i>GP</i>&quot;, 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&#039;s name imported
       into the global scope. So if you have a GET value named
       &quot;<i>userid</i>&quot;, and provide a prefix
       &quot;<i>pref_</i>&quot;, then you&#039;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">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;will&nbsp;import&nbsp;GET&nbsp;and&nbsp;POST&nbsp;vars<br />//&nbsp;with&nbsp;an&nbsp;"rvar_"&nbsp;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">,&nbsp;</span><span style="color: #DD0000">"rvar_"</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$rvar_foo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</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(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites