RE: Comparison Operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chadwick, Russell wrote:
>
> The function this is from sometimes uses $_POST or $_GET input, so
> sometimes its comparing 1337 with '1337' and === would break that.
>
> so I'll have to use something like:
>
> if (($value == $curval) && !(is_string ($curval) && ($value == 0)))
>
> unless there is a better way

Hard to say, without knowing what the function is, what it's supposed to
do, who's calling it and why/when/where...

I'll take a wild stab at it, though, and suggest that if you care about
data types that much, then you should be converting your $_GET/$_POST to
(int) in the first place.

Plus, you should be converting your $_GET/$_POST data to (int) when
appropriate for your data scrubbing (security).

So, really, you should have:

<?php
  $curval = (int) (isset($_GET['curval']) ? $_GET['curval'] : 0);
  ...
  your_function(1337, $curval);
  ...
?>

Then you can use === in your function safely.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux