A "heterogeneous" syntax in php: $a && $b = $c;
$a = 1;
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$ a";
echo "b:$b";
echo "c:$c";
This is
a:1
b:3
c:3
$a = 0;
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$a" ;
echo "b:$b";
echo "c:$c";
This is
a:0
b:2
c:3
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$ a";
echo "b:$b";
echo "c:$c";
This is
a:1
b:3
c:3
$a = 0;
$b = 2;
$c = 3;
$a && $b = $c;
echo "a:$a" ;
echo "b:$b";
echo "c:$c";
This is
a:0
b:2
c:3
Analysis:
1: The priority of && and the assignment operator "=" is && has a higher priority, but in the red writing method, $a and $b do not do the AND operation first and then =$c. This understanding is equivalent to 1= $c, and writing 1=$c is wrong
2: The correct way to understand this alternative writing method is:
if($a){$b = $c}, that is, if $a is true, the assignment statement $b = $c will be executed; otherwise, the assignment statement will not be executed, so the result is not difficult to understand
Statement
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
4 weeks agoByDDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
4 weeks agoByDDD
Two Point Museum: All Exhibits And Where To Find Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use
