phpphp-shorttags

PHP Short hand tags 7.x


Just wondering, I have a codeigniter project that I have been asked to do some work on. Im also trying to (where I can) prepare the project for upgrading to php 7.x (currently on 5).

One thing Im confused about is the use of php short tags. I love them but it seems they are being removed in 7?

So my question is, should I be removing them? The problem is, they make the code so much more readable, why are they removing it?

So for example:

<?php if ($product->price_discounted > 0)
{
    echo "<p class='discounted price'>" . $product->price_discounted . "</p>" 
}
?>

vs

<? if ($product->price_discounted > 0): ?>
    <p class='discounted price'><?= $product->price_discounted ?></p>
<? endif; ?>

I would much rather the second version, but whenever I run my project on php7 these don't work. Am I missing something or are they really removed?

FYI: I have short tags on in php.ini


Solution

  • Is the correct php.ini being loaded?

    <?php phpinfo(); ?>
    

    Check for Loaded Configuration File