Bug #14349: UTF8_ENCODE conflicts with Type Juggling
| From: | ruud at stress dot utwente dot nl | Date: | Wed, 05 Dec 2001 13:47:23 +0000 |
| Subject: | Bug #14349: UTF8_ENCODE conflicts with Type Juggling | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-72585@lists.php.net to get a copy of this message | ||
From: ruud@stress.utwente.nl
Operating system: Debian GNU/Linux 2.2
PHP version: 4.0.6
PHP Bug Type: XML related
Bug description: UTF8_ENCODE conflicts with Type Juggling
Hi,
Please take a look at this PHP script.
<?php
for($j=0; $j<1000; $j++) {
$result=71.95;
$price=utf8_encode($result);
$price = $price * 2.2 / 2.2;
echo "$price<br>\n";
}
?>
This script should just output 1000x exactly the same but as you can see,
the script sometimes returns "71" instead of "71.95".
Seems to have to do something with type juggling. If we explecitly cast
price to a float, ["$price=(float)utf8_encode($result);"] the script
returns only the correct value.
--
Edit bug report at: http://bugs.php.net/?id=14349&edit=1