| Topic:
PHP & MySQL
Displaying Information & Variables
There are four ways of escaping from HTML and entering "PHP code mode":
1. <? echo ("this is the simplest, an SGML processing instruction\n"); ?>
2. <?php echo("if you want to serve XML documents, do like this\n"); ?>
3. <script language="php"> echo ("some editors (like FrontPage) don't
like processing instructions"); </script>
4. <% echo ("You may optionally use ASP-style tags"); %> <%= $variable; # This is a shortcut for "<%echo .." %>
Instruction Seperation
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:
<?php echo "This is a test"; ?>
<?php echo "This is a test" ?>
Comments
Comments in PHP are similar to comments that are used in HTML. The PHP comment syntax always begins with a special character sequence and all text that appears between the start of the comment and the end will be ignored by the browser.
In HTML a comment's main purpose is to serve as a note to you, the web developer or to others who may view your website's source code. However, PHP's comments are different in that they will not be displayed to your visitors. The only way to view PHP comments is to open the PHP file for editing. This makes PHP comments only useful to PHP programmers.
In case you forgot what an HTML comment looked like, see our example below.
HTML Code:
<!--- This is an HTML Comment -->
|