Re: [Fwd: php...]

From: Date: Sun, 01 Apr 2001 01:35:57 +0000
Subject: Re: [Fwd: php...]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-46477@lists.php.net to get a copy of this message
PHP has type juggling feature. PHP4 supports "total equality"(?) operator "===". If you need variable to be match for both type and value. Use "===", then you can avoid type juggling. http://www.php.net/manual/en/language.types.type-juggling.php http://www.php.net/manual/en/language.operators.comparison.php Regards, -- Yasuo Ohgaki > I'm sure you appreciate the importance of transitive equality in programming > languages (especially they all aspire to be pseudo-mathematical), which is > why I think you'll appreciate this. > > <?php > > $a = "0"; > $b = 0; > $c = ""; > $d = " "; > > $a == $b // T > $b == $c // T > $a == $c // F!! > > $b == $c // T > $b == $d // T > $c == $d // F!! > > ?> > > Perl, of course, outputs the expected values: $a, $b, $c and $d are equal > under '==', and only $a and $b are equal under 'eq'. PHP's > '===' operator > (its equivalent to 'eq') says that $a, $b, $c and $d are all different. > > Doesn't that seem like a fundamental flaw? How can equality NOT be > transitive?? How can anyone be expected to write programs in such an > environment? > > D > > >

« previous php.general (#46477) next »