php-doc-en/reference/var/functions/import-request-variables.xml
Yannick Torres 2d7efe3dc8 fix markup
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@279918 c90b9560-bf6c-de11-be94-00142212c4b1
2009-05-04 21:23:55 +00:00

137 lines
4.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<refentry xml:id="function.import-request-variables" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>import_request_variables</refname>
<refpurpose>Import GET/POST/Cookie variables into the global scope</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>import_request_variables</methodname>
<methodparam><type>string</type><parameter>types</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>prefix</parameter></methodparam>
</methodsynopsis>
<para>
Imports GET/POST/Cookie variables into the global scope. It is useful if
you disabled <link linkend="ini.register-globals">register_globals</link>,
but would like to see some variables in the global scope.
</para>
<para>
If you're interested in importing other variables into the global scope,
such as <varname>$_SERVER</varname>, consider using <function>extract</function>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>types</parameter></term>
<listitem>
<para>
Using the <parameter>types</parameter> 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.
</para>
<note>
<para>
Note that the order of the letters matters, as when using
"<literal>GP</literal>", the
POST variables will overwrite GET variables with the same name. Any
other letters than GPC are discarded.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>prefix</parameter></term>
<listitem>
<para>
Variable name prefix, prepended before all variable's name imported
into the global scope. So if you have a GET value named
"<literal>userid</literal>", and provide a prefix
"<literal>pref_</literal>", then you'll get a global variable named
<varname>$pref_userid</varname>.
</para>
<note>
<para>
Although the <parameter>prefix</parameter> parameter is optional, you
will get an <link linkend="errorfunc.constants.errorlevels.e-notice"><constant>E_NOTICE</constant></link> 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 <link
linkend="ini.error-reporting">error reporting</link> level.
</para>
</note>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>import_request_variables</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// This will import GET and POST vars
// with an "rvar_" prefix
import_request_variables("gp", "rvar_");
echo $rvar_foo;
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><varname>$_REQUEST</varname></member>
<member><link linkend="ini.register-globals">register_globals</link></member>
<member><link linkend="language.variables.predefined">Predefined Variables</link></member>
<member><function>extract</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->