Re: problem with intval and !=

From: Date: Thu, 23 Oct 2003 15:21:42 +0000
Subject: Re: problem with intval and !=
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-167295@lists.php.net to get a copy of this message
This is getting weird by the minute. I changed the script: if ($number != $value) { echo "Bad"; } else { echo "Good"; // echoes Good!!!!!! } to: ($number != $value) ($number !== $value) ($number === $value) and I get the Good stuff... At this point, I think I have to change the procedure. This is not good. Any sugestions on how to now if the user types an integer number in a field? Cesar Curt Zirzow wrote:
* 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


« previous php.general (#167295) next »