本文整理匯總了PHP中Phone::homePhones方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phone::homePhones方法的具體用法?PHP Phone::homePhones怎麽用?PHP Phone::homePhones使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phone
的用法示例。
在下文中一共展示了Phone::homePhones方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
h4 {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
display: block;
}
</style>
<div class="container">
<div class="row">
<div class="col-md-8">
<h2>Téléphones</h2>
<div class="row">
<?php
foreach (Phone::homePhones() as $phone) {
if (Promotion::getPromotionByPhoneId($phone->id)) {
$phone->promotionPrice = $phone->price - Promotion::getPromotionByPhoneId($phone->id)->percent * 0.01 * $phone->price;
}
echo '<div class="col-md-4 col-sm-6 col-xs-12" style="text-align: center">';
echo '<div style="border: 1px solid #ededed; padding: 30px; margin: 20px 0;">';
echo '<a href="index.php?page=product&id=' . $phone->id . '">';
echo '<img src="' . Phone::getPhoneThumbnail($phone->id) . '" alt="' . $phone->name . '" style="width: 100px;">';
echo '<h4>' . $phone->name . '</h4>';
echo '</a>';
if (isset($phone->promotionPrice)) {
echo '<span class="badge old-price" style="background-color: transparent; color: #777;">' . number_format($phone->price, 2, ',', ' ') . ' €</span> <span class="badge" style="background: #e74c3c;">' . number_format($phone->promotionPrice, 2, ',', ' ') . ' €</span>';
} else {
echo '<span class="badge">' . number_format($phone->price, 2, ',', ' ') . ' €</span>';
}
echo '</div>';