ASP Style
Microsoft ASP pages employ a similar strategy, delimiting static from dynamic syntax by
using a predefined character pattern, opening dynamic syntax with <%, and concluding
with %>. If you??™re coming from an ASP background and prefer to continue using this
escape syntax, PHP supports it. Here??™s an example:
<%
print "This is another PHP example.";
%>
?– Caution ASP-style syntax was removed as of PHP 6.
CHAPTER 3 ?– PHP BASICS 59
Embedding Multiple Code Blocks
You can escape to and from PHP as many times as required within a given page. For
instance, the following example is perfectly acceptable:
$date = "July 26, 2007";
?>
Today's date is =$date;?>
As you can see, any variables declared in a prior code block are ???remembered??? for
later blocks, as is the case with the $date variable in this example.
Commenting Your Code
Whether for your own benefit or for that of a programmer later tasked with maintaining
your code, the importance of thoroughly commenting your code cannot be
overstated. PHP offers several syntactical variations, each of which is introduced in
this section.
Single-Line C++ Syntax
Comments often require no more than a single line. Because of its brevity, there is no
need to delimit the comment??™s conclusion because the newline (\n) character fills this
need quite nicely.
Pages:
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144