|
Posted by Rick Emery on 01/22/06 00:56
Quoting tg-php@gryffyndevelopment.com:
> 3. if ($cardID = '' || is_int($cardID))
> As someone mentioned, $cardID = '' makes an assignment, doesn't
> test for true/false. Change to $cardID == ''. And this statement
> SHOULD come up "true" as a whole because $cardID = '' should always
> be true (unless the assignment fails). So regardless of
> is_int($cardID) succeeding or failing, $cardID = '' should be true
> so this statement will always be true.
A trick I read about during my time of learning best practices: if
comparing against a literal or constant, place the literal or constant
on the left side of the expression. For example,
if ('' == $cardID) {
instead of
if ($cardID == '') {
That way, if you accidentally use "=" instead of "==", you should get
an error because you can't assign something to a literal or constant.
Hope this helps somebody,
Rick
--
Rick Emery
"When once you have tasted flight, you will forever walk the Earth
with your eyes turned skyward, for there you have been, and there
you will always long to return"
-- Leonardo Da Vinci
Navigation:
[Reply to this message]
|