[ciapug] yeah, weakly typed languages

Dave J. Hala Jr. dave at 58ghz.net
Wed Apr 4 11:45:02 CDT 2007


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
-- 



More information about the ciapug mailing list