From a93fc8b46f30318aab0c0870b339c82423e3b330 Mon Sep 17 00:00:00 2001 From: Torben Wilson Date: Sun, 25 Nov 2001 22:08:36 +0000 Subject: [PATCH] Major prose fixups, some XML cleanups, and a couple of typo fixes. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@63248 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/basic-syntax.xml | 194 +++++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 84 deletions(-) diff --git a/language/basic-syntax.xml b/language/basic-syntax.xml index 259f2f0ae4..bf9706b628 100644 --- a/language/basic-syntax.xml +++ b/language/basic-syntax.xml @@ -1,7 +1,7 @@ - - - Basic syntax + + + Basic syntax - - Escaping from HTML + + Escaping from HTML - - 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. - + + 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. + - - 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: - + + There are four sets of tags which can be used to denote blocks of + PHP code. Of these, only two (<?php. . .?> and <script + language="php">. . .</script>) are always available; the + others can be turned on or off from the + php.ini 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 + <?php. . .?> form to conform to the XML. + + + + The tags supported by PHP are: + @@ -83,75 +98,80 @@ - - The first way is only available if short tags have been - enabled. This can be done - - by enabling the short_open_tag - configuration setting in the PHP config file, or by compiling PHP with the - --enable-short-tags option to configure. - + + The first way is only available if short tags have been + enabled. This can be done via the short_tags + function (PHP 3 only), by enabling the short_open_tag configuration + setting in the PHP config file, or by compiling PHP with the + --enable-short-tags option to configure. + - - The second way is the generally preferred method, as it allows for the - next generation of XHTML to be easily implemented with PHP. - + + 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. + - - The fourth way is only available if ASP-style tags have been - enabled using the asp_tags - configuration setting. + + The fourth way is only available if ASP-style tags have been + enabled using the asp_tags + configuration setting. Support for ASP-style tags was added in 3.0.4. - + + - - The closing tag for the block will include the immediately - trailing newline if one is present. - + + 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. + - - PHP allows you to use structures like this: - Advanced escaping + + PHP allows you to use structures like this: + Advanced escaping This is true. + ?> This is false. ]]> - - - This works as expected, because PHP handles text within ?> and - <?php as an echo statement. - - + + This works as expected, because when PHP hits the > 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 echo or + print or somesuch. + + + + + Instruction separation + + + Instructions are separated the same as in C or Perl - terminate + each statement with a semicolon. - + + The closing tag (?>) also implies the end of the statement, so + the following are equivalent: - - Instruction separation - - - Instructions are separated the same as in C or Perl - terminate - each statement with a semicolon. - - - The closing tag (?>) also implies the end of the statement, so the - following are equivalent: - - - + + ]]> - - + + + + - - Comments + + Comments - - PHP supports 'C', 'C++' and Unix shell-style comments. For example: + + PHP supports 'C', 'C++' and Unix shell-style comments. For example: - + ]]> - + + - - The "one-line" comment styles actually only comment to the - end of the line or the current block of PHP code, whichever - comes first. - - + + The "one-line" comment styles actually only comment to the end of + the line or the current block of PHP code, whichever comes + first. + + + This is an example.>/h1>

The header above will say 'This is an example'. ]]> - - + + - - You should be careful not to nest 'C' style comments, which can - happen when commenting out large blocks. + + You should be careful not to nest 'C' style comments, which can + happen when commenting out large blocks. + - - + + ]]> - - + + +