torben          Sun Nov 25 17:08:36 2001 EDT

  Modified files:              
    /phpdoc/en/language basic-syntax.xml 
  Log:
  
  Major prose fixups, some XML cleanups, and a couple of typo fixes. 
  
  
Index: phpdoc/en/language/basic-syntax.xml
diff -u phpdoc/en/language/basic-syntax.xml:1.20 
phpdoc/en/language/basic-syntax.xml:1.21
--- phpdoc/en/language/basic-syntax.xml:1.20    Fri Nov 23 16:51:23 2001
+++ phpdoc/en/language/basic-syntax.xml Sun Nov 25 17:08:36 2001
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.20 $ -->
-  <chapter id="language.basic-syntax">
-   <title>Basic syntax</title>
+<!-- $Revision: 1.21 $ -->
+ <chapter id="language.basic-syntax">
+  <title>Basic syntax</title>
 
    <!--
    
@@ -46,20 +46,35 @@
      oop   : has been revised by Kristian, DONE.
    -->
    
-   <sect1 id="language.basic-syntax.phpmode">
-    <title>Escaping from HTML</title>
+  <sect1 id="language.basic-syntax.phpmode">
+   <title>Escaping from HTML</title>
   
-    <para>
-     When PHP starts to handle file, it will just output the text
-     it encounters. So if you have a HTML-file, and you change its
-     extension to .php, your file will keep working.
-    </para>
-
-    <para>
-     If you want to insert php-statements at some point in your
-     file, you'll need to indicate so to php, by entering "PHP mode"
-     in either of the following ways:
-    </para>
+   <para>
+    When PHP parses a file, it simply passes the text of the file
+    through until it encounters one of the special tags which tell it
+    to start interpreting the text as PHP code. The parser then
+    executes all the code it finds, up until it runs into a PHP
+    closing tag, which tells the parser to just start passing the text
+    through again. This is the mechanism which allows you to embed PHP
+    code inside HTML: everything outside the PHP tags is left utterly
+    alone, while everything inside is parsed as code.
+   </para>
+
+   <para>
+    There are four sets of tags which can be used to denote blocks of
+    PHP code. Of these, only two (&lt;?php. . .?&gt; and &lt;script
+    language="php"&gt;. . .&lt;/script&gt;) are always available; the
+    others can be turned on or off from the
+    <filename>php.ini</filename> configuration file. While the
+    short-form tags and ASP-style tags may be convenient, they are not
+    as portable as the longer versions. Also, if you intend to embed
+    PHP code in XML or XHTML, you will need to use the
+    &lt;?php. . .?&gt; form to conform to the XML.
+   </para>
+
+   <para>
+    The tags supported by PHP are:
+   </para>
 
     <para>
      <example>
@@ -83,75 +98,80 @@
      </example>
     </para>
 
-    <para>
-     The first way is only available if short tags have been
-     enabled. This can be done 
-     <!-- via the <function>short_tags</function> function,-->
-     by enabling the <link linkend="ini.short-open-tag">short_open_tag</link>
-     configuration setting in the PHP config file, or by compiling PHP with the
-     --enable-short-tags option to <command>configure</command>.
-    </para>
-
-    <para>
-     The second way is the generally preferred method, as it allows for the
-     next generation of XHTML to be easily implemented with PHP.
-    </para>
-
-    <para>
-     The fourth way is only available if ASP-style tags have been
-     enabled using the <link linkend="ini.asp-tags">asp_tags</link>
-     configuration setting.
+   <para>
+    The first way is only available if short tags have been
+    enabled. This can be done via the <function>short_tags</function>
+    function (PHP 3 only), by enabling the <link
+    linkend="ini.short-open-tag">short_open_tag</link> configuration
+    setting in the PHP config file, or by compiling PHP with the
+    --enable-short-tags option to <command>configure</command>.
+   </para>
+
+   <para>
+    Again, the second way is the generally preferred method, as it
+    allows for the the use of PHP in XML-conformant code such as
+    XHTML.
+   </para>
+
+   <para>
+    The fourth way is only available if ASP-style tags have been
+    enabled using the <link linkend="ini.asp-tags">asp_tags</link>
+    configuration setting.
 
     <note>
      <para>Support for ASP-style tags was added in 3.0.4.</para>
-    </note></para>
+    </note>
+   </para>
 
-    <para>
-     The closing tag for the block will include the immediately
-     trailing newline if one is present.
-    </para>
+   <para>
+    The closing tag for the block will include the immediately
+    trailing newline if one is present. Also, the closing tag
+    automatically implies a semicolon; you do not need to have a
+    semicolon terminating the last line of a PHP block.
+   </para>
     
-    <para> <!-- TODO: find a better place for this para -->
-     PHP allows you to use structures like this:
-     <example><title>Advanced escaping</title>
+    <para>
+    PHP allows you to use structures like this:
+    <example><title>Advanced escaping</title>
      <programlisting role="php">
 <![CDATA[
 <?php
-
 if (boolean-expression) {
     ?>
 <strong>This is true.</strong>
     <?php
 } else {
-    >
+    ?>
 <strong>This is false.</strong>
     <?php
 }
     ?>
 ]]>
      </programlisting>
-               </example>
-     
-     This works as expected, because PHP handles text within ?&gt; and
-     &lt;?php as an <function>echo</function> statement.
-     <!-- without the parsing if vars, that is (hopefully?) obvious -->
-    </para>
-
-   </sect1>
-
-   <sect1 id="language.basic-syntax.instruction-separation">
-    <title>Instruction separation</title>
-
-    <simpara>
-     Instructions are separated the same as in C or Perl - terminate
-     each statement with a semicolon.</simpara>
-
-    <para>
-     The closing tag (?&gt;) also implies the end of the statement, so the
-     following are equivalent:
+    </example>
+    This works as expected, because when PHP hits the &gt; closing
+    tags, it simply starts outputting whatever it finds until it hits
+    another opening tag. The example given here is contrived, of
+    course, but for outputting large blocks of text, dropping out of
+    PHP parsing mode is generally more efficient than sending all of
+    the text through <function>echo</function> or
+    <function>print</function> or somesuch.
+   </para>
+  </sect1>
+  
+  <sect1 id="language.basic-syntax.instruction-separation">
+   <title>Instruction separation</title>
+   
+   <simpara>
+    Instructions are separated the same as in C or Perl - terminate
+    each statement with a semicolon.</simpara>
+
+   <para>
+    The closing tag (?&gt;) also implies the end of the statement, so
+    the following are equivalent:
 
-     <informalexample>
-      <programlisting role="php">
+    <informalexample>
+     <programlisting role="php">
 <![CDATA[
 <?php
     echo "This is a test";
@@ -159,17 +179,19 @@
 
 <?php echo "This is a test" ?>
 ]]>
-      </programlisting>
-     </informalexample></para></sect1>
+     </programlisting>
+    </informalexample>
+   </para>
+  </sect1>
 
-   <sect1 id="language.basic-syntax.comments">
-    <title>Comments</title>
+  <sect1 id="language.basic-syntax.comments">
+   <title>Comments</title>
    
-    <para>
-     PHP supports 'C', 'C++' and Unix shell-style comments. For example:
+   <para>
+    PHP supports 'C', 'C++' and Unix shell-style comments. For example:
 
     <informalexample>
-                <programlisting role="php">
+     <programlisting role="php">
 <![CDATA[
 <?php
     echo "This is a test"; // This is a one-line c++ style comment
@@ -180,27 +202,30 @@
 ?>
 ]]>
      </programlisting>
-    </informalexample></para>
+    </informalexample>
+   </para>
 
-    <simpara>
-     The "one-line" comment styles actually only comment to the
-     end of the line or the current block of PHP code, whichever
-     comes first.</simpara>
-     <informalexample>
-                 <programlisting role="php">
+   <simpara>
+    The "one-line" comment styles actually only comment to the end of
+    the line or the current block of PHP code, whichever comes
+    first.
+   </simpara>
+   <informalexample>
+    <programlisting role="php">
 <![CDATA[
 <h1>This is an <?php # echo "simple";?> example.>/h1>
 <p>The header above will say 'This is an example'.
 ]]>
-                 </programlisting>
-          </informalexample> 
+    </programlisting>
+   </informalexample> 
 
-    <simpara>
-     You should be careful not to nest 'C' style comments, which can
-     happen when commenting out large blocks.</simpara>
+   <simpara>
+    You should be careful not to nest 'C' style comments, which can
+    happen when commenting out large blocks.
+   </simpara>
 
-    <informalexample>
-     <programlisting role="php">
+   <informalexample>
+    <programlisting role="php">
 <![CDATA[
 <?php
  /* 
@@ -209,8 +234,9 @@
 ?>
 ]]>
     </programlisting>
-        </informalexample></sect1>
-  </chapter>
+   </informalexample>
+  </sect1>
+ </chapter>
  
 <!-- Keep this comment at the end of the file
 Local variables:


Reply via email to