Home > Backend Development > PHP Tutorial > PHP操作符优先级问题

PHP操作符优先级问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:51:31
Original
1171 people have browsed it

一段代码

$a=0;
var_dump(1 != $a = 1);
Copy after login
Copy after login

按照优先级比,!=比=高,为何输出结果是false,求解答

回复内容:

一段代码

$a=0;
var_dump(1 != $a = 1);
Copy after login
Copy after login

按照优先级比,!=比=高,为何输出结果是false,求解答

这个可以看鸟哥 @laruence 的文章。

这里如果严格按照操作符优先级顺序,!=操作以后得到一个不能被赋值的左值,最终会造成语法错误;PHP里有对表达式内赋值的兼容,所以这时是先执行的赋值操作。

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template