Click to See Complete Forum and Search --> : What's <?= $someVariable ?>


Jazztronik
02-21-2008, 02:41 AM
<?= $someVariable ?>

Is it another way to express:

<?php echo $someVariable ?> ???

I didn't see this before.

MrCoder
02-21-2008, 03:31 AM
Pretty much, but I wouldn't use it.

Jazztronik
02-21-2008, 05:31 AM
why? if it's the same, it would make the HTML code where it is embedded clearer.

NogDog
02-21-2008, 11:16 AM
The <? and <?= tags will only work if the short_open_tag (http://us.php.net/manual/en/ini.core.php#ini.short-open-tag) option is enabled in your PHP configuration. Depending on the target use of your application, you may not be able to guarantee that this option is turned on. Additionally, it is now considered a "best practice" to not have it turned on, since it conflicts with <?xml tags. Also, it may not be available at all in PHP 6. Therefore, my recommendation is simply to never use short tags, as the tiny bit of extra typing now can save you from a lot of grief later.

MrCoder
02-22-2008, 03:32 AM
The <? and <?= tags will only work if the short_open_tag (http://us.php.net/manual/en/ini.core.php#ini.short-open-tag) option is enabled in your PHP configuration. Depending on the target use of your application, you may not be able to guarantee that this option is turned on. Additionally, it is now considered a "best practice" to not have it turned on, since it conflicts with <?xml tags. Also, it may not be available at all in PHP 6. Therefore, my recommendation is simply to never use short tags, as the tiny bit of extra typing now can save you from a lot of grief later.

What he said :)