什么是一个感叹号前一个函数的真正含义是在PHP [英] What does an exclamation mark before a function really mean in PHP

查看:127
本文介绍了什么是一个感叹号前一个函数的真正含义是在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屋!

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