note 12147 modified in language.operators by felipe

From: Date: Tue, 22 Jul 2008 19:04:19 +0000
Subject: note 12147 modified in language.operators by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142546@lists.php.net to get a copy of this message
Other Language books' operator precedence section usually include "(" and ")" - with exception of a Perl book that I have. (In PHP "{" and "}" should also be considered also). However, PHP Manual is not listed "(" and ")" in precedence list. It looks like "(" and ")" has higher precedence as it should be. Note: If you write following code, you would need "()" to get expected value. <?php $bar = true; $str = "TEST". ($bar ? 'true' : 'false') ."TEST"; ?> Without "(" and ")" you will get only "true" in $str. (PHP4.0.4pl1/Apache DSO/Linux, PHP4.0.5RC1/Apache DSO/W2K Server) It's due to precedence, probably. --was-- Other Language books' operator precedence section usually include "(" and ")" - with exception of a Perl book that I have. (In PHP "{" and "}" should also be considered also). However, PHP Manual is not listed "(" and ")" in precedence list. It looks like "(" and ")" has higher precedence as it should be. Note: If you write following code, you would need "()" to get expected value. $bar = true; $str = "TEST". ($bar ? 'true' : 'false') ."TEST"; Without "(" and ")" you will get only "true" in $str. (PHP4.0.4pl1/Apache DSO/Linux, PHP4.0.5RC1/Apache DSO/W2K Server) It's due to precedence, probably. http://php.net/manual/en/language.operators.php

« previous php.notes (#142546) next »