Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between '<?=' and '<?php'? [duplicate]

Tags:

php

Possible Duplicate:
Are PHP short tags acceptable to use?

I was looking at some sample code and I noticed that the code used

<?=

instead of

<?php

as opening tags, the closing tags were the same as usual, but I was just wondering if there is any different functionality between the two? The file extension of the sample code is also .phtml instead of .php

like image 530
Carwyn Stephen Avatar asked Jun 18 '26 10:06

Carwyn Stephen


2 Answers

<?= is not the same as <?php

<?= is the same as <?php echo

<? is the same as <?php

like image 156
LeeR Avatar answered Jun 20 '26 23:06

LeeR


<?= is shorthand for <?php echo ...

It's used like so:

<?=$var1?>

instead of:

<?php echo $var1; ?>
like image 26
Rocket Hazmat Avatar answered Jun 20 '26 23:06

Rocket Hazmat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!