PHP如果速记和回声在一行 - 可能吗? [英] PHP if shorthand and echo in one line - possible?

查看:146
本文介绍了PHP如果速记和回声在一行 - 可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最好的,首选的写作方式如果是速记单行,例如:

What's the best, preferred way of writing if shorthand one-liner such as:

expression ? $foo : $bar

情节扭曲:我需要 echo $ foo echo $ bar 。任何疯狂的伎俩? :)

Plot twist: I need to echo $foo or echo $bar. Any crazy tricks? :)

推荐答案

<?=(expression) ? $foo : $bar?>

编辑:

edit: here's a good read for you on the topic

编辑: a href =https://stackoverflow.com/questions/14188397/why-are-echo-short-tags-permanently-enabled-as-of-php-5-4>更多内容阅读

这篇关于PHP如果速记和回声在一行 - 可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆