Saturday, August 18, 2012

Tags in php

Short-Tags

For the less-motivated, an even shorter delimiter syntax is available. Known as short-tags, this
syntax foregoes the php reference required in the default syntax. However, to use this feature,
you need to enable PHP’s short_open_tag directive. An example follows:
<?
print "This is another PHP example.";
?>
 Although short-tag delimiters are convenient, keep in mind that they clash with XML, and thus
XHTML, syntax. Therefore for conformance reasons you should use the default syntax.

Script

Historically, certain editors, Microsoft’s FrontPage editor in particular, have had problems
dealing with escape syntax such as that employed by PHP. Therefore, support for another
mainstream delimiter variant, <script>, was incorporated into PHP:
<script language="php">
print "This is another PHP example.";
</script>

■Tip Microsoft's FrontPage editor also recognizes ASP-style delimiter syntax, introduced next.
 

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 syntax, PHP supports
it. Here’s an example:
<%
print "This is another PHP example.";
%>

No comments:

Post a Comment