In PHP what does this <?= ? > tag represent?

Asked

Viewed 210 times

6

In PHP what this tag represents ?

Opening tag:

<?= 

Closing tag:

?>

2 answers

10


This syntax is a shortcut to this:

<?php echo  ; ?>

Before PHP 5.4 the option short tags should be enabled to use this shortcut. In PHP 5.4 this option is always available.

So much so that this syntax is specified in echo documentation.

Example:

<p>Meu nome é <?=$nome?></p>

amounts to

<p>Meu nome é <?php echo $nome; ?></p>

Before this change of PHP 5.4, the use of echo implicit was problematic as the short opening tags <? ?>are confused with XML instructions, and usually hosts in general keep this option off.

As the sign of = would serve in theory for disambiguation in these cases, it was decided to enable this option separately from the configuration of short tags.

3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.