[PHP-DOC] cvs: phpdoc /en/language variables.xml From: Philip Olson (philip <email protected>)
Date: 06/28/02

philip Fri Jun 28 20:52:17 2002 EDT

  Modified files:
    /phpdoc/en/language variables.xml
  Log:
  Added <?php ?> to PHP code.
  Added ?> <?php to HTML code (until role="HTML" exists).
  Changed $Count to $count in setcookie example.
  
  
Index: phpdoc/en/language/variables.xml
diff -u phpdoc/en/language/variables.xml:1.50 phpdoc/en/language/variables.xml:1.51
--- phpdoc/en/language/variables.xml:1.50 Sat Jun 22 23:03:36 2002
+++ phpdoc/en/language/variables.xml Fri Jun 28 20:52:16 2002
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.50 $ -->
+<!-- $Revision: 1.51 $ -->
  <chapter id="language.variables">
   <title>Variables</title>
   
@@ -30,6 +30,7 @@
     <informalexample>
      <programlisting role="php">
 <![CDATA[
+<?php
 $var = "Bob";
 $Var = "Joe";
 echo "$var, $Var"; // outputs "Bob, Joe"
@@ -37,6 +38,7 @@
 $4site = 'not yet'; // invalid; starts with a number
 $_4site = 'not yet'; // valid; starts with an underscore
 $täyte = 'mansikka'; // valid; 'ä' is ASCII 228.
+?>
 ]]>
      </programlisting>
     </informalexample>
@@ -285,8 +287,10 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $a = 1;
 include "b.inc";
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -301,6 +305,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $a = 1; /* global scope */
 
 function Test()
@@ -309,6 +314,7 @@
 }
 
 Test();
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -329,6 +335,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $a = 1;
 $b = 2;
 
@@ -341,6 +348,7 @@
 
 Sum();
 echo $b;
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -362,6 +370,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $a = 1;
 $b = 2;
 
@@ -372,6 +381,7 @@
 
 Sum();
 echo $b;
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -393,12 +403,14 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 function Test ()
 {
     $a = 0;
     echo $a;
     $a++;
 }
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -416,12 +428,14 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 function Test()
 {
     static $a = 0;
     echo $a;
     $a++;
 }
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -444,6 +458,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 function Test()
 {
     static $count = 0;
@@ -455,54 +470,7 @@
     }
     $count--;
 }
-]]>
- </programlisting>
- </informalexample>
-
- <simpara>
- Static initializers are evaluated when a function is defined, not
- when it is executed. Thus you cannot make reference to any other
- variables or initialize a static variable with the result of a
- function call. The following example suggests a way around this:
- </simpara>
-
- <informalexample>
- <programlisting role="php">
-<![CDATA[
-function Test()
-{
- static $magic_quotes_initialized = false;
- static $magic_quotes;
- if (!$magic_quotes_initialized) {
- $magic_quotes = get_magic_quotes_gpc();
- $magic_quotes_initialized = true;
- }
-
- // function body
-}
-]]>
- </programlisting>
- </informalexample>
-
- <simpara>
- If the function you are calling has predictable return values, for
- example, if it can never return <literal>null</literal>, this
- can be further simplified (note the use of the identity operator
- <literal>===</literal>):
- </simpara>
-
- <informalexample>
- <programlisting role="php">
-<![CDATA[
-function Test()
-{
- static $magic_quotes = null;
- if ($magic_quotes === null) {
- $magic_quotes = get_magic_quotes_gpc();
- }
-
- // function body
-}
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -519,6 +487,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 function test_global_ref() {
     global $obj;
     $obj = &new stdclass;
@@ -533,6 +502,7 @@
 var_dump($obj);
 test_global_noref();
 var_dump($obj);
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -555,6 +525,7 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 function &get_instance_ref() {
     static $obj;
 
@@ -586,6 +557,7 @@
 echo "\n";
 $obj2 = get_instance_noref();
 $still_obj2 = get_instance_noref();
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -626,7 +598,9 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $a = "hello";
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -641,7 +615,9 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 $$a = "world";
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -656,7 +632,9 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 echo "$a ${$a}";
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -668,7 +646,9 @@
    <informalexample>
     <programlisting role="php">
 <![CDATA[
+<?php
 echo "$a $hello";
+?>
 ]]>
     </programlisting>
    </informalexample>
@@ -726,10 +706,12 @@
       <title>Simple form variable</title>
       <programlisting role="php">
 <![CDATA[
+?>
 <form action="foo.php" method="post">
     Name: <input type="text" name="username"><br>
     <input type="submit">
 </form>
+<?php
 ]]>
       </programlisting>
      </example>
@@ -767,6 +749,7 @@
       <title>More complex form variables</title>
       <programlisting role="php">
 <![CDATA[
+?>
 <form action="array.php" method="post">
     Name: <input type="text" name="personal[name]"><br>
     Email: <input type="text" name="personal[email]"><br>
@@ -778,6 +761,7 @@
         </select>
     <input type="submit">
 </form>
+<?php
 ]]>
       </programlisting>
      </example>
@@ -798,7 +782,9 @@
      <informalexample>
       <programlisting role="php">
 <![CDATA[
+?>
 <input type="image" src="image.gif" name="sub">
+<?php
 ]]>
       </programlisting>
      </informalexample>
@@ -840,7 +826,9 @@
     <informalexample>
      <programlisting role="php">
 <![CDATA[
+<?php
 setcookie("MyCookie[]", "Testing", time()+3600);
+?>
 ]]>
      </programlisting>
     </informalexample>
@@ -856,9 +844,11 @@
      <title>SetCookie Example</title>
      <programlisting role="php">
 <![CDATA[
-$Count++;
-setcookie("Count", $Count, time()+3600);
-setcookie("Cart[$Count]", $item, time()+3600);
+<?php
+$count++;
+setcookie("Count", $count, time()+3600);
+setcookie("Cart[$count]", $item, time()+3600);
+?>
 ]]>
      </programlisting>
     </example>
@@ -875,7 +865,9 @@
      <informalexample>
       <programlisting role="php">
 <![CDATA[
+<?php
 echo $HOME; /* Shows the HOME environment variable, if set. */
+?>
 ]]>
       </programlisting>
      </informalexample>
@@ -902,7 +894,9 @@
      variable name. For the reason, look at it:
      <programlisting role="php">
 <![CDATA[
+<?php
 $varname.ext; /* invalid variable name */
+?>
 ]]>
      </programlisting>
      Now, what the parser sees is a variable named

-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php