Bug #14349 Updated: UTF8_ENCODE conflicts with Type Juggling

From: Date: Wed, 05 Dec 2001 18:06:17 +0000
Subject: Bug #14349 Updated: UTF8_ENCODE conflicts with Type Juggling
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-72664@lists.php.net to get a copy of this message
ID: 14349 User updated by: ruud@stress.utwente.nl Reported By: ruud@stress.utwente.nl Status: Open Bug Type: XML related Operating System: Debian GNU/Linux 2.2 PHP Version: 4.0.6 New Comment: The problem does not occur "always" and probably not on the first "run" of the script. So if you just run the script one time, everything might look good. Try to reload the script many times to see the bug. It seems like a heavy system load exploits the bug. I reproduced the bug on five different (i386) systems with Linux, running different versions of the Linux Kernel and Apache, using versions of PHP ranging from 4.0.3 to 4.0.6. The bug occurs on every system. Previous Comments: ------------------------------------------------------------------------ [2001-12-05 08:47:23] ruud@stress.utwente.nl 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 this bug report at http://bugs.php.net/?id=14349&edit=1

« previous php.dev (#72664) next »