|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22173 Strange behaviour with the string 'inf'
Submitted: 2003-02-11 13:55 UTC Modified: 2003-02-16 10:50 UTC
Avg. Score:4.0 ± 1.2
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: afenoy at wol dot es Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.3.1-dev OS: Linux
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.
Block user comment
Status: Assign to:
Bug Type:
From: afenoy at wol dot es
New email:
PHP Version: OS:


 [2003-02-11 13:55 UTC] afenoy at wol dot es
Very strange bug: (double) of any string begining with 'inf'  evaluates as 'INF', but only in strings of more than 3 characters a comparison with a integer results in same bug. 

Try this script:

echo 'somestring'   > 1 ? 1 : 0, '<br>';
echo 'inf'          > 1 ? 1 : 0, '<br>';
echo 'info'         > 1 ? 1 : 0, '<br>';
echo 'inf at begin' > 1 ? 1 : 0, '<br>';
echo (double)'somestring',   '<br>';
echo (double)'inf',          '<br>';
echo (double)'inf at begin', '<br>';

Expected results are:


But real results are:




Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-11 17:11 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

When performing a mathematical calculation between a number and a string in PHP, PHP will attempt to convert the string to an integer. Since PHP supports things such as INF certain strings, such as 'inf more data' will be converted to INF.
 [2003-02-12 04:38 UTC] afenoy at wol dot es
Ok, double-checked the documentation: this behavior of 'inf...' strings seems absolutely undocumented.

Auto-convertion of any string that begins by 'inf' in infinite seems to me inadequate. Considering that this 'functionality' has not been documented, would be desirable to create a new predefined constant INF or a new data type INF or a new reserved word INF to treat infinite numbers, in the same form in which NULL, TRUE or FALSE correspond to 
predefined values. Consider that when we locked up 'NULL', 'TRUE' or 'FALSE' in a string, they are not evaluated like the corresponding constants. The same behavior would be desirable with a (new) predefined constant INF.

And at least an error exists now in the form in which the strings that begin by 'inf' are treated. The strings of more than 3 characters ('information', 'infant' ...) are evaluated as INF in the comparisons with numbers, but the string 'inf', with single three characters, does not. Try this:

echo (double)'information', '<br>';
echo (double)'inf'        , '<br>';

echo 'information' > 1 ? 1 : 0, '<br>';
echo 'inf'         > 1 ? 1 : 0, '<br>';



 [2003-02-12 05:16 UTC] afenoy at wol dot es
Re-open: at least with single three characters 'inf', this is a bug and not a 'functionality'.
 [2003-02-12 12:46 UTC]
We're already discussing this - so reopening was valid.
 [2003-02-12 22:02 UTC]
verified with PHP 4.3.1-dev..

 [2003-02-16 10:50 UTC]
This bug is the result of differing implementations of strtod() in the various libc libraries. For example glibc considers (double) "info" to be equivalent to INF while in Win32 the same operation will return 0.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 02:05:45 2022 UTC