note 24797 added to language.operators

From: Date: Wed, 28 Aug 2002 18:43:28 +0000
Subject: note 24797 added to language.operators
Groups: php.notes 
Request: Send a blank email to php-notes+get-35932@lists.php.net to get a copy of this message
It should be noted that PHP's ?: operator associates left to right. In C and in C++, the ?: operator associates right to left. Thus: 1 ? 2 : 3 ? 4 : 5; has the value 4 in PHP and the value 2 in C and in C++. I find it curious that they would reverse the associativity of an operator from its "accepted" sense, but yet they didn't fix the precedence of the bitwise operators. Thus: if(A & 7 == 5) groups like: if(A & (7 == 5)) It is a trap for the unlucky. -- http://www.php.net/manual/en/language.operators.php http://master.php.net/manage/user-notes.php?action=edit+24797 http://master.php.net/manage/user-notes.php?action=delete+24797 http://master.php.net/manage/user-notes.php?action=reject+24797

« previous php.notes (#35932) next »