[ciapug] yeah, weakly typed languages

carl-olsen at mchsi.com carl-olsen at mchsi.com
Wed Apr 4 11:49:30 CDT 2007


I've never used the "===" or "!==" operators, but I can clearly see now what their purpose is.  Barry is using version 4.4.0 and I'm using version 5.2.1 and both of us are getting the same exact thing.  That should prove that the behavior is intentional and it explains to me what the "===" and "!==" operators are doing.

 -------------- Original message ----------------------
From: "Dave J. Hala Jr." <dave at 58ghz.net>
> I *think* I saw that in reference to php 5  or soon to be  php 6
> somewhere...
> 
> On Wed, 2007-04-04 at 11:36, carl-olsen at mchsi.com wrote:
> > I have never used this, but isn't "===" a function that might solve this?
> > 
> > I think "==" is equality, and "===" is absolute equality.
> > 
> > Carl
> > 
> >  -------------- Original message ----------------------
> > From: Barry Von Ahsen <barry at vonahsen.com>
> > >   echo "phpversion: ".phpversion()."<br>";
> > >   $a = "01234";
> > >   $b = "1234";
> > >   echo "a:". $a."<br>";
> > >   echo "b:". $b."<br>";
> > >   if($a == $b) { echo "a==b"; } else { echo "a!=b"; } echo "<br>";
> > >   if($a === $b) { echo "a===b"; } else { echo "a!==b"; } echo "<br>";
> > >   echo "gettype(a):". gettype($a)."<br>";
> > >   echo "gettype(b):". gettype($b)."<br>";
> > > 
> > >   $c = "0foo";
> > >   $d = "foo";
> > >   echo "c:". $c."<br>";
> > >   echo "d:". $d."<br>";
> > >   if($c == $d) { echo "c==d"; } else { echo "c!=d"; } echo "<br>";
> > >   if($c === $d) { echo "c===d"; } else { echo "c!==d"; } echo "<br>";
> > > 
> > > output:
> > > phpversion: 4.4.0
> > > a:01234
> > > b:1234
> > > a==b
> > > a!==b
> > > gettype(a):string
> > > gettype(b):string
> > > c:0foo
> > > d:foo
> > > c!=d
> > > c!==d
> > > 
> > > I totally understand why "01234"==1234, but not why "01234"=="1234".  If 
> > > I'm doing string=>string, no conversion should happen.  However, if it 
> > > does, why doesn't "0foo"=>0 and "foo"=>0 so "0foo"=="foo" also?!?
> > > 
> > > -barry
> > > 
> > > 
> > > _______________________________________________
> > > ciapug mailing list
> > > ciapug at cialug.org
> > > http://cialug.org/mailman/listinfo/ciapug
> > 
> > 
> > _______________________________________________
> > ciapug mailing list
> > ciapug at cialug.org
> > http://cialug.org/mailman/listinfo/ciapug
> -- 
> 
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug




More information about the ciapug mailing list