Reply to RE: [PHP] Comparison Operator

Your name:

Reply:


Posted by Richard Lynch on 10/04/04 11:05

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация