混合的更清潔的方式,我有這個PHP塊PHP開關的情況下使用HTML
<?php switch ($_GET['class_id']) { ?>
<?php case 1: ?>
<img src="<?php print $result['standard_image'] == "" ? "/pre_config/css/images/blue-png2.png" : "/shop_possystems/image/{$result['standard_image']}" ?>" alt="" />
<?php break; ?>
<?php case 2: ?>
<img src="<?php print $result['business_image'] == "" ? "/pre_config/css/images/blue-png2.png" : "/shop_possystems/image/{$result['business_image']}" ?>" alt="" />
<?php break; ?>
<?php case 3: ?>
<img src="<?php print $result['premium_image'] == "" ? "/pre_config/css/images/blue-png2.png" : "/shop_possystems/image/{$result['premium_image']}" ?>" alt="" />
<?php break; ?>
<?php default: ?>
<img src="<?php print $result['standard_image'] == "" ? "/pre_config/css/images/blue-png2.png" : "/shop_possystems/image/{$result['standard_image']}" ?>" alt="" />
<?php break; ?>
<?php } ?>
但這似乎有點messy..any建議
可以減少PHP標籤 – 2011-05-06 16:44:53
聖牛,這是一個很多的標籤! – Kelly 2011-05-06 16:46:08
我的大腦傷害:( – Hannes 2011-05-06 16:56:30