php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31026 Problem with type conversion
Submitted: 2004-12-08 20:37 UTC Modified: 2004-12-20 13:34 UTC
From: tobi at knmm dot de Assigned:
Status: Closed Package: Variables related
PHP Version: 4.3.10RC3-dev OS: Linux 2.6.8 (Debian sarge)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tobi at knmm dot de
New email:
PHP Version: OS:

 

 [2004-12-08 20:37 UTC] tobi at knmm dot de
Description:
------------
A very strange problem occurs on my webserver. If you run the provided code via http://knmm.de/bug.php a few times, in about 1 out of 10 times the second line of output is "$price is a double with value 34". This shows up randomly.
Running the script on the commandline of the same machine doesn't show this behaviour.

--
Tobi

Reproduce code:
---------------
$price = '34.90';

echo "\$price is a ".gettype($price)." with value $price\n";
settype($price,'double');
echo "\$price is a ".gettype($price)." with value $price\n";

(also available via http://knmm.de/bug.phps)

Expected result:
----------------
$price is a string with value 34.90
$price is a double with value 34.9


Actual result:
--------------
$price is a string with value 34.90
$price is a double with value 34


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-18 00:52 UTC] tobi at knmm dot de
Now, with the CVS version the script says '34,9' instead of 34.9 (with 4.3.9 it was only '34').
This solves my problem, which was that calculations with variables, type-converted from string to float had gone wrong sometimes. 
But it's still very strange.
I figured out that the problem only occurrs if the apache webserver with php on it already ran for a few hours.
 [2004-12-20 13:34 UTC] sniper@php.net
Fixed -> closed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC