|
Posted by Mike Ford on 10/04/12 11:05
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
On 10 January 2005 21:20, 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)))
I would cast both sides of the comparison to the same type and then use the
identity operator. So, depending on exactly what kind of comparison you
want (and maybe how safe your data are!), either of:
if ((int)$value === (int)$curval)
if (string)$value === (string)$curval)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
Navigation:
[Reply to this message]
|