I l @ ve RuBoard |
Like ASP, PHP uses what I call "open-close bracket" syntax. In a classic ASP program, the syntax starts with an open bracket ( <% ) and ends with a close bracket ( %> ): <% Response.write("A classic ASP program") %> Much the same is done in PHP. The open-close bracket syntax starts with <?php and ends with ?> : <?php print("A PHP program"); ?> PHP also allows a style of syntax that is familiar to client-side script developers. This style of syntax starts with <SCRIPT LANGUAGE="php"> and ends with </SCRIPT> : <SCRIPT LANGUAGE="php"> print("test"); </SCRIPT> If you have a background in ASP, never fear. PHP also lets you use ASP-style open-close bracket syntax: <% print("A PHP program") %> However, for this style of open-close bracket syntax to work, you must edit the php.ini file: asp_tags = On This is set to Off by default. Multiline ProgramsMultiline PHP programs have additional syntax: <?php print("This is your first"); print(" PHP Program"); ?> Note that PHP requires an end-of-line character ”the semicolon (;). If you run the program with no end-of-line character, as in the following code, you will receive a Parse error message: <?php print("This is your first") print(" PHP Program") ?> If you have never used end-of-line characters , they can often trip you up. If you receive a Parse error message when writing your web applications, check for an end-of-line character at the line number given in the error message, as shown in Figure 3.1. Figure 3.1. A Parse error message.
|
I l @ ve RuBoard |