我想我会使用preg_match()
with的结果(bool)
,但我不太确定。我觉得不清楚结果是不是true
还是false
。示例 1:
if (((bool) preg_match($pattern, $string, $matches)) === true)
示例 2:
if (((bool) !preg_match($pattern, $string, $matches)) === true)
示例 3:
if (((bool) preg_match($pattern, $string, $matches)) === false)
示例 4:
if (((bool) !preg_match($pattern, $string, $matches)) === false)
另一种想法是:有结果的事情将来也安全吗0
?1
你有这方面的经验吗?你能报告什么?
编辑 0:鉴于if
没有比较运算符,问题得到了扩展。0
总是false
和1
总是true
?_
示例 5:
if ((preg_match($pattern, $string, $matches)))
示例 6:
if ((!preg_match($pattern, $string, $matches)))
这个对吗?(preg_match($pattern, $string, $matches))
= 0
| 1
(!preg_match($pattern, $string, $matches))
= true
| false
不是!
30秒到达战场