我可以在PHP类方法返回语句中使用三元组吗?

Ste*_*hen 4 php ternary-operator return-value

我可以这样做吗?(我现在无法测试它自己看)

public function overSimplifiedTernaryTest($condition = false) {
    return ($condition) ? 'someString' : 'someOtherString';
}
Run Code Online (Sandbox Code Playgroud)

HoL*_*ieR 5

它可以工作,下次你可以使用ideone.com测试你的代码,而不是问问题.

您的代码:http://ideone.com/2oHkF

您还可以参考此问题以获取额外的在线工具来测试您的代码.