if I enable short tag = true, then I can use like below
<?=$variableName ?>
Instead of
<?php echo $variableName ?>
I have below questions:
Short tags <? doSomething(); ?>
are considered to be a bad practice because they are not XML compliant... whether you care about that or not is another issue.
Short echos <?= $myString ?>
are not a bad practice, it's just not the best. PHP is a templating engine, however much better engines are available (Twig, Mustache, Smarty, etc). Most frameworks include their own templating engine so short tags don't need to be used.
Up to and including PHP 5.3, these types of tags were considered to be the same thing. Since PHP 5.4 however they've been separated out and short echo is allowed without enable-short-tags
being turned on. Since PHP 5.3 is no longer supported, the only concern is if you're being forced to use an unsupported version, which obviously has it's own implications. :)
It is not bad practice, per se. New versions of PHP have it enabled, but older versions may or may not have it enabled. So, if you want everyone to be able to run your code then you should go with <?php
. If you do not care about older versions of PHP (i.e. no backwards compatibility concerns) then... do as you like.
No server dependencies. You just need to enable it.
Frameworks generally have guidelines for contributors. Which one you use personally has nothing to do with the framework, however; it has to do with if it is enabled or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With