HTML and PHP languages being nested within the same file, it was necessary to define a syntax allowing to dissociate them during processing :
<? php
marks the begining of a PHP section?>
marks the end of a PHP sectionWhen the file is a pure PHP script (without display or HTML) it is preferable not to place the closing tag at the end of the file to avoid unwanted displays in the client's browser.
The short tags <?= $Variable?>
display the output of a code
or the content of a variable without the need of `echo function. Here is a
example:
<!-- Both line do the same disply -->
<?php echo 'PHP tag<br>'; ?>
<?= 'PHP tag<br>' ?>
In practice, the use of short tags is preferred (when suited) to avoid burdening the source codes.
The following code creates three PHP varaiables and displays a table with three rows. Use short tags to display the variable content in each row of the table:
<?php
$firstRow="This text must be placed in the first row";
$secondRow="This text must be placed in the second row";
$thirdRow="This text must be placed in the third row";
?>
<table border="1">
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
Here is the expected result: