Yii Framework Forum: Difference B/w <?= And <?php Echo - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Difference B/w <?= And <?php Echo

#1 User is offline   calebic 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 16-February 14

Posted 02 March 2014 - 04:30 PM

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!
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 02 March 2014 - 04:34 PM

Actually there's no difference since short echo tags are always available since 5.4.

So if you found this in Yii2, time to submit an issue to github.
God is real unless declared as integer
0

#3 User is offline   calebic 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 16-February 14

Posted 02 March 2014 - 04:45 PM

Thanks ORey - here is the url to the issue i submitted. I look forward to the day I'm smart enough to help fix these things!

https://github.com/y...ii2/issues/2601
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users