Created
December 25, 2015 15:49
-
-
Save anhtuank7c/76b7e12ca7071a1af8f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lưu ý: Việc cái nào nhúng vào cái nào chỉ là cách mình nói về 2 kiểu viết này | |
//1. nhúng php vào html | |
<?php foreach($products as $product):?> | |
<div class="product"> | |
<h3 class="title"><?= $product->title?></h3> | |
<div class="content"> | |
<p><?= $product->content?></p> | |
</div> | |
</div> | |
<?php endforeach;?> | |
//2. nhúng html vào php | |
<?php | |
foreach($products as $product) { | |
echo '<div class="product">'; | |
echo '<h3 class="title">' . $product->title . '</h3>'; | |
echo '<div class="content"><p>' . $product->content . '</p></div>'; | |
echo '</div>'; | |
} | |
?> | |
// Bạn tự so sánh xem cách nào thích hợp thì viết. kết quả xuất ra tương đương nhau. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment