· PHP – Syntax
- This tutorial shows how
to embed PHP code into Web Page.
tags (delimitators) are used to define start and end of PHP code.
needed so that Web Browser engine knows which parts of Web Page should be
interpreted as PHP.
- If Web
Page has .php extension browser will assueme that <? and <% delimitators
define start of PHP code.
similar to .asp web pages where browser assumes that <% delimitator defines
start of ASP code.
- There are
4 different Delimitiation Variants discussed below.
- This is
deafult syntax for labeling code as PHP script.
<?php echo "This is another
Syntax allows you to ommit php from opening delimitator.
- To use
this syntax, you need to enable PHP’s short_open_tag directive in php.ini.
<? echo "This is another
PHP example."; ?>
Syntax can be used when you want to quickly escape to and from PHP to output a
bit of dynamic text.
<?="This is another PHP
- This ia
equivalent to following line but allows you to ommit echo keyword making your
code more readable:
<? echo "This is
another PHP example."; ?>
for Script Syntax was added because some editors, like FrontPage, had problems
with other Syntax forms:
print "This is another
- ASP Style
Syntax was introduced for those comming from ASP background but was removed as
of PHP 6:
<% print "This is another
PHP example."; %>
- By using
delimitaros you can freely mix PHP and HTML code as this example demonstrates.
echo "Welcome to my Web site!";?></title>
$date = "July