当前位置:网站首页>$a && $b = $c what???
$a && $b = $c what???
2022-06-26 07:02:00 【話吥哆先森丶】
$a && $b = $c;
$a = 1;
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$a";
echo "b:$b";
echo "c:$c";
//这样是
a:1
b:3
c:3
$a = 0;
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$a";
echo "b:$b";
echo "c:$c";
//这样是
a:0
b:2
c:3
解析:
- && 和赋值运算符“=”的优先级是&&优先级高,但是加红的写法中并不是 $a和$b先做与运算然后 =$c,这么理解相当于 1=$c, 而 1=$c这样的写法是错误的
- 这种另类的写法正确的理解方式为:
if($a){$b = $c},即如果$a为真,则执行赋值语句$b = $c;否则不执行此赋值语句,这样结果不难理解
边栏推荐
- Paths with a certain value in a binary tree (1) (2) (3) (Sword finger offer)
- How to open an account in flush? Is it safe to open an account online?
- Mysql操作数据库
- Research Report on market development prospect and investment strategy of China's water soluble film industry 2022-2027
- 一芯实现喷雾|WS2812驱动|按键触摸|LED显示|语音播报芯片等功能,简化加湿器产品设计
- [cellular automata] Based on cellular automata, realize the traffic flow problem of expressway toll station, with matlab code
- i3wm 获取window class
- Redis系列——5种常见数据类型day1-3
- 一文深入底层分析Redis对象结构
- 同花顺究竟如何开户,网上开户是否安全么?
猜你喜欢
Here comes the apple ar/vr device exclusive system! Or named realityos
[digital signal processing] basic sequence (unit step sequence | relationship between unit step sequence and unit pulse sequence | rectangular sequence | relationship between rectangular sequence and
Guide to "avoid dismissal during probation period"
淺析一道經典題
Hudi compilation of data Lake architecture
QTreeWidget And QTableWidget
【推荐一款实体类转换工具 MapStruct,性能强劲,简单易上手 】
数据湖架构之Hudi编译篇
i3wm 获取window class
Professional course - Code question record
随机推荐
If you meet a female driver who drives didi as an amateur, you can earn 500 yuan a day!
China polyphenylene oxide Market Development Prospect and Investment Strategy Research Report 2022-2027
Solve the problem of cross domain invalidation of cookies in the new version of Google Chrome browser
[digital signal processing] basic sequence (basic sequence lists | unit pulse sequence | unit pulse function | discrete unit pulse function | difference between unit pulse function and discrete unit p
数据挖掘是什么?
My SQL (II)
unity之EasyAR使用
Analysis report on market demand and investment competitiveness of China's cyclohexanone industry (2022 Edition)
What is data mining?
php array_merge详解
i3wm 获取window class
Research Report on China's surfactant market demand and future investment opportunities 2022
Promise API for getting started with the web
Spark3.3.0源码编译补充篇-抓狂的证书问题
[path planning] robot path planning based on improved artificial potential field with matlab code
Fmt Must the result of println (true) be true?
Market survey of China's coal to liquid industry and analysis report on investment competitiveness during the "14th five year plan" 2022-2027
LabVIEW arduino TCP / IP Remote Intelligent Home System (Project section - 5)
web入门之 Promise API
屏幕共享推荐