The <?php
tag is used to explicitly mark the start of PHP code in a file. It is considered the recommended and portable way to open
PHP blocks. On the other hand, the <?=
tag is a shorthand for <?php
echo and is specifically used to output variables
or expressions directly without using the echo statement. Not using these tags can make the code less readable and harder to maintain, as it deviates
from the standard conventions followed by most PHP developers.
Noncompliant code example
<?
$foo = 1;
?>
Compliant solution
<?php
$foo = 1;
?>