Page 1 of 1
Whats the syntax for multiple ===
Posted: Tue Aug 22, 2006 5:39 pm
by Shendemiar
Code: Select all
if($s0 === $s1 === $s2 === $s3 === $s4 === $s5 === $s6 === $s7 === $s8 === $s9 === $s10)
Posted: Tue Aug 22, 2006 5:41 pm
by feyd
Posted: Tue Aug 22, 2006 5:44 pm
by Shendemiar
The line gives error!
Code: Select all
Parse error: parse error, unexpected T_IS_IDENTICAL
Posted: Tue Aug 22, 2006 5:48 pm
by feyd
What's the logic you're trying to accomplish, in plain words, not code?
Posted: Tue Aug 22, 2006 5:49 pm
by Shendemiar
feyd wrote:What's the logic you're trying to accomplish, in plain words, not code?
To see if they are all the same.
Posted: Tue Aug 22, 2006 5:53 pm
by feyd
Code: Select all
if ($s0 === $s1 and $s1 === $s2 ...)
would be one possible route.
If they are all truely named as such, there is an algorithmic way as well using variable variables.
Posted: Tue Aug 22, 2006 6:03 pm
by Shendemiar
All the $s are equal strings...
How come
Code: Select all
echo var_export((((((((((($s0 == $s1) == $s2) == $s3) == $s4) == $s5) == $s6) == $s7) == $s8) == $s9) == $s10));
Gives True
While
Code: Select all
echo var_export((((((((((($s0 === $s1) === $s2) === $s3) === $s4) === $s5) === $s6) === $s7) === $s8) === $s9) === $s10));
Gives false
In my logic they both should give false, since ($s1==$s2) == true, and (true==$s3)==false
And without the ((((( )))))'s they should both give true, but they give error.
Posted: Tue Aug 22, 2006 6:06 pm
by feyd
$s0 === $s1 returns a boolean type. Since none of the other $s* are boolean, they would immediately fail the identical check.
Posted: Tue Aug 22, 2006 6:08 pm
by Shendemiar
That explains the later, but how come the first one returns true?
Posted: Tue Aug 22, 2006 6:10 pm
by feyd
a nonempty string compared to a boolean true returns true.
The code doesn't work the way you are wishing it to.
Posted: Tue Aug 22, 2006 6:11 pm
by Shendemiar
Ok, thanks, time tomove on.
