RE: [PHP-DEV] php short circuit bug?

From: Date: Fri, 30 Sep 2016 10:57:45 +0000
Subject: RE: [PHP-DEV] php short circuit bug?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-96181@lists.php.net to get a copy of this message
Sorry, I did not saw that there were an == on the right side, and thought that It was an assignement…. Thanks a lot Best regards, Pascal KISSIAN De : Thomas Punt [mailto:tpunt@hotmail.co.uk] Envoyé : vendredi 30 septembre 2016 12:51 À : Pascal KISSIAN <php-mailing-list@lool.fr> Objet : Re: [PHP-DEV] php short circuit bug? Hi! The warning is being emitted from the IF statement body, where you're not actually performing an assignment, but a comparison instead: $t_aa["bb"]=="cc"; -Tom _____ From: Pascal KISSIAN <php-mailing-list@lool.fr <mailto:php-mailing-list@lool.fr> > Sent: 30 September 2016 11:45 To: internals@lists.php.net <mailto:internals@lists.php.net> Subject: [PHP-DEV] php short circuit bug? Hi everybody, Perhaps am I making a mistake, but the following code fragment: <?php $t_aa = array(); if ( !isset($t_aa["bb"]) || ($t_aa["bb"]=="") ) $t_aa["bb"]=="cc"; ?> Emits the following notice: PHP Notice: Undefined index: bb in test.php on line 4 The php documentation : http://php.net/manual/en/language.operators.logical.php <http://php.net/manual/en/language.operators.logical.php> PHP: Logical Operators - Manual php.net Logical Operators; Example Name Result $a and $b: And: TRUE if both $a and $b are TRUE. $a or $b: Or: TRUE if either $a or $b is TRUE. $a xor $b: Xor: TRUE if either ... states in exemple 1 that short circuit is implemented. In my example as !isset($t_aa["bb"]) true, then the second expression ($t_aa["bb"]=="")should not be evaluated! Is it a php bug? Or am i missing something? Cheers, Pascal KISSIAN

« previous php.internals (#96181) next »