PHP Syntax

When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tells PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in different documents, as the PHP parser ignores everything outside of a pair of opening and closing tags.

PHP includes a short echo tag <?= which is a short-hand to the more verbose <?php echo.

Types Of Syntax.

1. Normal Tag.

If you want to process something, you should use the normal tag.

<?php
$var = 3;
$var2 = 2;
$var3 = $var+$var2;
if($var3){//result}
?>
2. Short echo Tag.

If you want to just print single text or something, you should use a shorthand version .<?= $var ?>

3. Short echo Tag.

short tag are by default available but can be disabled by short_open_tag = Off and also disabled by default if php will be built with –disable–short–tags()

As the short tags can be disabled so only use the normal and short echo tag.

Back to top button