Specifications

Different tag styles are available. This is the short style. If you have some problems running
this script, it might be because short tags are not enabled in your PHP installation. Lets look at
this in more detail.
PHP Tag Styles
There are actually four different styles of PHP tags we can use. Each of the following frag-
ments of code is equivalent.
Short style
<? echo “<p>Order processed.”; ?>
This is the tag style that will be used in this book. It is the default tag that PHP develop-
ers use to code PHP.
This style of tag is the simplest and follows the style of an SGML (Standard Generalized
Markup Language) processing instruction. To use this type of tagwhich is the shortest
to typeyou either need to enable short tags in your config file, or compile PHP with
short tags enabled. You can find more information on how to do this in Appendix A.
XML style
<?php echo “<p>Order processed.”; ?>
This style of tag can be used with XML (Extensible Markup Language) documents. If
you plan to serve XML on your site, you should use this style of tag.
SCRIPT style
<SCRIPT LANGUAGE=’php’> echo “<p>Order processed.”; </SCRIPT>
This style of tag is the longest and will be familiar if youve used JavaScript or
VBScript. It can be used if you are using an HTML editor that gives you problems with
the other tag styles.
ASP style
<% echo “<p>Order processed.”; %>
This style of tag is the same as used in Active Server Pages (ASP). It can be used if you
have enabled the asp_tags configuration setting. You might want to use this style of tag if
you are using an editor that is geared towards ASP or if you already program in ASP.
PHP Statements
We tell the PHP interpreter what to do by having PHP statements between our opening and
closing tags. In this example, we used only one type of statement:
echo “<p>Order processed.”;
PHP Crash Course
C
HAPTER 1
1
PHP CRASH
COURSE
15
03 7842 CH01 3/6/01 3:39 PM Page 15