我有一段代碼,我懷疑可以用更有效的方式編寫代碼,但對於某些PHP查詢仍然有點生疏。凝聚式PHP查詢
是否有寫下面的查詢有更好的方式:
<?php
if(qtrans_getLanguage()=='en'): echo 'Latest News'; endif;
if(qtrans_getLanguage()=='it'): echo 'Ultime notizie'; endif;
if(qtrans_getLanguage()=='de'): echo 'Aktuelle Nachrichten'; endif;
if(qtrans_getLanguage()=='zh'): echo '最新消息'; endif;
if(qtrans_getLanguage()=='es'): echo 'Últimas noticias'; endif;
if(qtrans_getLanguage()=='fr'): echo 'Dernières nouvelles'; endif;
?>
你可以嘗試一個switch語句http://php.net/manual/en/control-structures.switch.php – Andy