DEV Community

applepie
applepie

Posted on • Edited on

Laravel php tag not working

Hi devs! I'm currently learning Laravel and I find that php tag <?php is not working, but the <?= tag works perfectly. I searched for some explanations but could not find any. I always prefer the first tag than the latter.

Top comments (4)

Collapse
 
rafaacioly profile image
Rafael Acioly • Edited

the tag <?= is equivalent an <?php echo ..., so if you want to write some logic use <?php ... and if you just want to show something you can write <?= ...;

<?php foreach($users as $user) {
    ...
}
?>
<?= "Hello world!" ?>
Collapse
 
ns01 profile image
Eduardo Reyes

Are you doing an echo?

<?php echo "something"; ?>
Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
ns01 profile image
Eduardo Reyes

Pretty sure it has happen to all of us at some point! No stupid questions :)