Home > Backend Development > PHP Tutorial > PHP这个语句是什么意思呢解决思路

PHP这个语句是什么意思呢解决思路

WBOY
Release: 2016-06-13 10:05:16
Original
845 people have browsed it

PHP这个语句是什么意思呢
!$status && $status = $pm['msgtoid'] && $pm['new'];

PHP这个语句是什么意思呢

------解决方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];

如果 !$status == 1 (即 $status == 0)
并且 $status = $pm['msgtoid'] (赋值后的$status不为0)
并且 $pm['new']不为0

那么。。。。。
------解决方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];
!$status返回一个BOOL值,表示非$status
非$status为真的时候才会执行后面的赋值操作。
$status = $pm['msgtoid'] && $pm['new'];
$pm['msgtoid'] && $pm['new']返回的也是BOOL值。
只有当$pm['msgtoid']和$pm['new']都不为空,不等于0,不等于false,不为NULL,时才返回true.
------解决方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];
运算顺序:
(!$status) && ($status = $pm['msgtoid'] && $pm['new']);
等于 (!$status) && $pm['msgtoid'] && $pm['new'];
这样写是将$pm['msgtoid'] && $pm['new']的运算结果在赋值给$status, 可能是为了下面程序的使用,要么就是蛋疼

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template