[geeklog-devel] COM_isAnonUser
Joe Mucchiello
joe at ThrowingDice.com
Sat Dec 29 10:20:53 EST 2007
At 09:50 AM 12/29/2007, you wrote:
>Joe Mucchiello wrote:
>
> > return $uid <= 1;
>
>Calling COM_isAnonUser() when $_USER['uid'] is not set would result in
>this comparing
>
> '' <= 1
>
>which is a little odd.
>
>There is some redundant code in that function, but some of it is necessary.
Arguably it is the default parameter at fault here. $uid is a number
and its default should be 0, not ''.
PHP is a typeless, interpretted language. string('') <= number(1) is
a perfectly valid expression that will always return true because the
string will be converted to number before the comparison. Again, it
is probably faster to let the Runtime do this conversion than to add
interpreter code that says "if (!empty)" in order to avoid "odd",
though perfectly valid behavior.
----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com
More information about the geeklog-devel
mailing list