[ciapug] yeah, weakly typed languages
Barry Von Ahsen
barry at vonahsen.com
Wed Apr 4 12:33:44 CDT 2007
=== is in 4, it's my second test for a===b
-barry
Dave J. Hala Jr. wrote:
> 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