aidan           Sat Sep 11 06:28:37 2004 EDT

  Modified files:              
    /phpdoc/en/faq      misc.xml 
  Log:
  Added register_globals example
  
http://cvs.php.net/diff.php/phpdoc/en/faq/misc.xml?r1=1.15&r2=1.16&ty=u
Index: phpdoc/en/faq/misc.xml
diff -u phpdoc/en/faq/misc.xml:1.15 phpdoc/en/faq/misc.xml:1.16
--- phpdoc/en/faq/misc.xml:1.15 Wed Aug  4 09:07:41 2004
+++ phpdoc/en/faq/misc.xml      Sat Sep 11 06:28:27 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.15 $ -->
+<!-- $Revision: 1.16 $ -->
  <chapter id="faq.misc">
   <title>Miscellaneous Questions</title>
   <titleabbrev>Miscellaneous Questions</titleabbrev>
@@ -95,6 +95,60 @@
     </answer>
    </qandaentry>
    
+   <qandaentry id="faq.misc.registerglobals">
+    <question>
+     <para>
+      How do I deal with register_globals
+     </para>
+    </question>
+    <answer>
+<para>
+ <example>
+  <title>Emulating Register Globals</title>
+  <para>
+   This will emulate register_globals On.
+  </para>
+  <programlisting role="php">
+<![CDATA[
+// Emulate register_globals on
+if (!ini_get('register_globals')) {
+    $superglobals = array($_SERVER, $_ENV,
+        $_FILES, $_COOKIE, $_POST, $_GET);
+    if (isset($_SESSION)) {
+        array_unshift($superglobals, $_SESSION);
+    }
+    foreach ($superglobals as $superglobal) {
+        extract($superglobal, EXTR_SKIP);
+    }
+    ini_set('register_globals', true);
+}
+]]>
+  </programlisting>
+  <para>
+   This will emulate register_globals Off.
+  </para>
+  <programlisting role="php">
+<![CDATA[
+// Emulate register_globals off
+if (ini_get('register_globals')) {
+    $superglobals = array($_SERVER, $_ENV,
+        $_FILES, $_COOKIE, $_POST, $_GET);
+    if (isset($_SESSION)) {
+        array_unshift($superglobals, $_SESSION);
+    }
+    foreach ($superglobals as $superglobal) {
+        foreach ($superglobal as $global) {
+            unset($GLOBALS[$global]);
+        }
+    }
+    ini_set('register_globals', false);
+}
+]]>
+  </programlisting>
+ </example>
+</para>
+    </answer>
+   </qandaentry>
   </qandaset>
  </chapter>
 

Reply via email to