Re: [PHP] problem with intval and !=

From: Curt Zirzow (php-general_at_zirzow.dyndns.org)
Date: 10/23/03


Date: Thu, 23 Oct 2003 15:09:52 +0000
To: php-general@lists.php.net


* Thus wrote Cesar Cordovez (phpguru@cesamo.com):
> Curt:
>
> My fault! You are right, but thats not what I want. $value comes from a
> form filled by a user. I want $value to be an integer. Not a float.
> So if the user types "12.3" the system has to send an error msg.

Yeah, after reading merek's response I realized I missed what
exactly your problem is.

>
> Therefore the procedure.
>
> By-the-way, Im using PHP 4.3.3 (on windows XP profesional. Don't say a
> thing!!! I rather work on my mac!) =)

Thats odd, I come up with a 'Bad' echo also. The only thing I can
think of is there is some sort of implicit casting happening to the
$value within the comparison. But it does seem very strange that
XP would cast but *nix doesn't

In that case test the condition reversed:
  if ($value != $number)

I'm at a loss as to why it doesn't work on your system.

Curt

-- 
"My PHP key is worn out"
  PHP List stats since 1997: 
	  http://zirzow.dyndns.org/html/mlists/


Relevant Pages