Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

Appendix D. PHP TAGS


There are several ways to mark an area of PHP script in a Web page, displayed below.
The results of the script, if any, will take the place in the final output. If a line break
follows the closing tag, it will be removed. This helps you write more readable code.


<?


?>


This is the classic method for marking PHP code. Many of the examples found on the
Internet use this method, probably because it's the method that's been available the
longest. PHP version 2 used this method except that the second question mark was
omitted.


This method is called "short tags" and support for it may be turned on or off. One way is
to use the short_tags function described in Chapter 11, "Time, Date, and
Configuration Functions." A directive in the php.ini file controls enabling short
tags for all scripts. You can also configure PHP to enable short tags before you compile
it.


<?php
?>


This method was added to make PHP scripts compatible with XML, which get confused
by the short tags described above.



Some text editors, Microsoft's Frontpage in particular, do not understand tags that start
with <?, so support for this longer tagging method was added.


<%


%>

Free download pdf