Re: Re: Minor engine patch to facilitate PECL/operator

From: Date: Fri, 17 Feb 2006 14:10:44 +0000
Subject: Re: Re: Minor engine patch to facilitate PECL/operator
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Jakub Vrana wrote:
Sara Golemon wrote:
with thanks to Sara! - because (not for the first time) your post allowed me to learn/understand some new stuff. (Sara seems to have a knack for explaining stuff in a way that dummies can [also] understand it - that a good thing[tm]!)
Yes, and that's the problem. $a > $b *isn't* read by the current parser as $a > $b, it's read as $b < $a.
For all normal PHP comparisons, the distinction is unimportant... 4 < 2 and 2 > 4 will both evaluate to false after all.
Array comparison is due this logic also strange: $a = array(0, 1); $b = array(1 => 0, 0 => 1);
I started playing with this because I didn't understand it. I could only make both the LT and the GT expressions equal true with these particular arrays. for instance if I changed them to: $a = array(0, 1); $b = array(0 => 1, 1 => 0); then the var_dump() statements give me: bool(true) bool(false) Personally I would never use a statement like ($a < $b) if $a and $b are arrays - mainly because I have no idea what that really means (array $a being 'less than' $b) so the determining whether $a is 'less than' $b is not much use. given that fact I'm not fussed whether array comparison (in such a way) is broken or not ... but I am very interested to here 'core people's advice on using this kind of expression syntax with arrays (I feel objects have the same problem as arrays with regard to what 'greater than'/'less than' really means when comparing to object variables).
var_dump($a < $b); // true var_dump($a > $b); // true $a is both less than and greater than $b. Jakub Vrana


Thread (19 messages)

« previous php.internals (#21902) next »