I have some php variables that I need to spit out in a template file.
Normally I would do <?php echo $var; ?> But I know you can also do <?=$var?> and it will do the same thing.
I know I’ve seen a setting for “enable php shorttags” or something like that. Meaning that the server will interpret both <? and <?php
My question is, do shorttags have to be allowed in order to the method of getting vars <?=$var?> ?
Thanks!
It depends on the PHP version.
As of 5.4.0,
<?=always works. Prior to that,short_open_tagneeds to be enabled in PHP.ini.See also: http://php.net/manual/en/ini.core.php
I’d avoid using them, for maximum portability.