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.

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!) =)

Cesar

Curt Zirzow wrote:

* Thus wrote Cesar Cordovez ([EMAIL PROTECTED]):

Can somebody explain me why is this happening?

$value = "12.3";
$number = intval($value);

echo "Number: $number, Value: $value<br>";
// echoes: Number: 12, Value: 12.3


I'm guessing you wondering why the .3 is removed.  Thats because
12.3 isn't an integer but a float.

$number = floatval($value);


if ($number != $value) {
        echo "Bad";
} else {
        echo "Good";  // echoes Good!!!!!!
}


The previous should be echoing "Bad". (I think!)


correct. If you use the floatval() it will echo "Good".

Curt

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to