什么是一个感叹号前一个函数的真正含义是在PHP [英] What does an exclamation mark before a function really mean in PHP
问题描述
正如标题,一个函数之前有哪些呢惊叹号真的在PHP中呢?
Just as in the title, what does an exclamation mark before a function really mean in PHP?
例如如下语句:
For example is the following statement:
if (!stripos($haystack, $needle)) {}
此相同
如果(stripos函数($大海捞针,$针)=== FALSE){}
或本
如果(stripos函数($大海捞针,$针)== FALSE){}
任何澄清是AP preciated
Any clarification would be appreciated
推荐答案
的!
preceding功能是一样的...
The !
preceding the function is the same as...
if (stripos($haystack, $needle) == FALSE) {}
这是相同的,因为它是一个 ==
比较不检查的类型。
这就是所谓的的否定元运算符的。它的翻转的布尔值(强迫为布尔如果需要的话)的值。
It's called the negation unary operator. It flips the Boolean value (coercing to Boolean if need be) of a value.
例如...
! 0; // True
! 1 ; // False
! ''; // True
! true; // False
!! 0 // False
的 !!
的技巧是无(布尔)在语言方便
演员。通过翻转值的两倍,您将获得其原始值的布尔版本。
The !!
trick is handy in languages without a (bool)
cast. By flipping a value twice, you get the Boolean version of its original value.
这篇关于什么是一个感叹号前一个函数的真正含义是在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!