|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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: 0 0 0 0 0 0 0 But real results are: 0 0 1 1 0 INF INF Saludos ?ngel PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 15:00:01 2025 UTC |
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>'; ?> Result: INF INF 1 0 Saludos ?ngel