cvs: phpdoc /en/faq using.xml
| From: | Philip Olson | Date: | Sun, 20 Apr 2008 06:56:40 +0000 |
| Subject: | cvs: phpdoc /en/faq using.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1543@lists.php.net to get a copy of this message | ||
philip Sun Apr 20 06:56:40 2008 UTC
Modified files:
/phpdoc/en/faq using.xml
Log:
Added a FAQ titled "How does the PHP directive register_globals affect me?"
http://cvs.php.net/viewvc.cgi/phpdoc/en/faq/using.xml?r1=1.35&r2=1.36&diff_format=u
Index: phpdoc/en/faq/using.xml
diff -u phpdoc/en/faq/using.xml:1.35 phpdoc/en/faq/using.xml:1.36
--- phpdoc/en/faq/using.xml:1.35 Thu Mar 20 02:04:21 2008
+++ phpdoc/en/faq/using.xml Sun Apr 20 06:56:40 2008
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.35 $ -->
+<!-- $Revision: 1.36 $ -->
<chapter xml:id="faq.using" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Using PHP</title>
<titleabbrev>Using PHP</titleabbrev>
@@ -99,6 +99,68 @@
</answer>
</qandaentry>
+ <qandaentry xml:id="faq.register-globals">
+ <question>
+ <para>
+ How does the PHP directive register_globals affect me?
+ </para>
+ </question>
+ <answer>
+ <para>
+ First, an explanation about what this ini setting does. Let's say the
+ following URL is used:
+ <literal>http://example.com/foo.php?animal=cat</literal>
+ and in <filename>foo.php</filename> we might have the following
+ PHP code:
+ </para>
+ <para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// Using $_GET here is preferred
+echo $_GET['animal'];
+
+// For $animal to exist, register_globals must be on
+// DO NOT DO THIS
+echo $animal;
+
+// This applies to all variables, so $_SERVER too
+echo $_SERVER['PHP_SELF'];
+
+// Again, for $PHP_SELF to exist, register_globals must be on
+// DO NOT DO THIS
+echo $PHP_SELF;
+?>
+]]>
+ </programlisting>
+ </para>
+ <para>
+ The code above demonstrates how register_globals creates a lot of
+ variables. For years this type of coding has been frowned upon, and for
+ years it's been disabled by default. Note that PHP 6 removes this
+ deprecated feature. So although most web hosts disable register_globals,
+ there are still outdated articles, tutorials, and books that require it
+ to be on. Plan accordingly.
+ </para>
+ <para>
+ See also the following resources for additional information:
+ <simplelist>
+ <member>The <link
linkend="ini.register-globals">register_globals</link> directive</member>
+ <member>The <link linkend="security.globals">security chapter about
register globals</link></member>
+ <member><link linkend="language.variables.external">Handling external
variables</link></member>
+ <member>Use <link
linkend="language.variables.superglobals">superglobals</link>
instead</member>
+ </simplelist>
+ </para>
+ <note>
+ <para>
+ In the example above, we used an <acronym>URL</acronym> that contained
+ a QUERY_STRING. Passing information like this is done through a GET HTTP
+ Request, so this is why the superglobal <varname>$_GET</varname> was used.
+ </para>
+ </note>
+ </answer>
+ </qandaentry>
+
<qandaentry xml:id="faq.using.wrong-order">
<question>
<para>