Hi All,
Can anyone help me understand the difference between
<?=
and
<?php echo
?
I’m new to Yii and Yii2 and looking at the view.php file created by gii, and I see …
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?php echo Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'method' => 'post',
],
]); ?>
</p>
In the code above, I see two instances of the Html::a method but I don’t really understand why one uses
<?=
and the other uses
<?php echo
If I change both references to use
<?=
it seems to echo the content just as
<?php echo
would.
Is there any difference between the two versions? Why does Yii use both options here?
Many thanks for your knowledge!