note 69022 deleted from language.operators by danbrown

From: Date: Fri, 30 Jan 2009 20:41:29 +0000
Subject: note 69022 deleted from language.operators by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150001@lists.php.net to get a copy of this message
Note Submitter: T Chan ---- In response to 26-Mar-2001 08:53, parens don't need to have precedence. There's only one way to convert them to a syntax tree. I can't think of a sensible reason it could be ambiguous either (and sensible language designers will make ( always pair with ) so there can't be any ambiguity). In response to 12-Aug-2005 08:47, you can do <?php $myvar OR ($myvar = 1); ?>, or the equivalent <?php !$myvar AND $myvar = 1; ?>, and if you have to use ifs, <?php if(!$myvar) { $myvar = 1; } ?> will do just fine (though in general, I'd be careful using boolean expressions as an indicator of success/failure when 0 could be a valid value. And you probably want to use isset($myvariable)). In response to the manual, associativity doesn't determine the order of evaluation - it determines how it's "bracketed": a=b=c=1 is equivalent to a=(b=(c=1)), but a is evaluated first (an important point if evaluating a has side-effects) <?php function one($str) { echo "$str"; return 1; } $a = array(1,2); $a[one("A")] = $a[one("B")] = 1; // outputs AB ?>

« previous php.notes (#150001) next »