我有一段代码,我怀疑可以用更有效的方式编写代码,但对于某些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