note 125280 added to language.operators.comparison

From: Date: Tue, 18 Aug 2020 12:29:08 +0000
Subject: note 125280 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-214985@lists.php.net to get a copy of this message
Both Null Coalescing ( ?? ) and Ternary ( ? : ) can work at a time. <?php $a = "user name"; echo $a = null ?? $a ? "sb" : "not found"; // it prints : sb //as null coalescing has null on left it goes to 2nd expr $a. $a is defined so //output will be the 1st expr of Ternay operator. ?> <?php echo $x = "" ?? "" ? : "not found"; // it prints: not found. // null coalescing has empty value of its left. so it prints right expr which is //also empty. so the output will be the 2nd expr of ternary(written in short) ?> <?php echo $x = "" ?? "" ?? "" ? : false; // prints nothing. // if you add var_dump() you see bool(false) ?> ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 37.111.205.246) ---- Manual Page -- http://php.net/manual/en/language.operators.comparison.php Edit -- https://master.php.net/note/edit/125280 Del: integrated -- https://master.php.net/note/delete/125280/integrated Del: useless -- https://master.php.net/note/delete/125280/useless Del: bad code -- https://master.php.net/note/delete/125280/bad+code Del: spam -- https://master.php.net/note/delete/125280/spam Del: non-english -- https://master.php.net/note/delete/125280/non-english Del: in docs -- https://master.php.net/note/delete/125280/in+docs Del: other reasons-- https://master.php.net/note/delete/125280 Reject -- https://master.php.net/note/reject/125280 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214985) next »