三元运算符 与 return

有三元运算符可以很好的代替if else简单语句

但是在使用的时候发现 与 return使用的时候 需要用这种形式

错误形式: $a ? return 1 ? return 0;

正确形式: return $a ? 1 : 0;

学习源头

https://zhidao.baidu.com/question/877310536831516932.html

posted @ 2018-05-03 17:28  段佳伟  阅读(3086)  评论(0编辑  收藏  举报