Re: Validating get and post data
| From: | @ Edwin | Date: | Tue, 03 Dec 2002 03:38:11 +0000 |
| Subject: | Re: Validating get and post data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126803@lists.php.net to get a copy of this message | ||
Hello,
"Matt" <mschroebel@epooch.com> wrote:
> I think what's happening here is a type issue. The comparison is returning
a
> boolean, so when $c != '0', the switch is true and the case is resolving
to
> true, and executing. But when $c == '0', with switch is (false), but the
> case is true. Change the case to
> ($c > chr(58) and $c < chr(58)):
> pass in '09090' and see what you get. Perhaps the case isn't the right
> structure for this test.
I think you're in the right track.
Running these would produce different results:
---------- script 1 ----------
$s = '0';
switch ($s){
case ($s > chr(47) && $s < chr(58)):
echo 'Yehey!';
break;
default:
echo 'Boo!';
}
---------- script 2 ----------
$s = 0;
switch ($s){
case ($s > chr(47) && $s < chr(58)):
echo 'Yehey!';
break;
default:
echo 'Boo!';
}
BTW, there's no problem if you use "if...else" clause...
- E