ID:               22173
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Verified
 Bug Type:         Scripting Engine problem
 Operating System: Linux
-PHP Version:      4.2.1
+PHP Version:      4.3.1-dev
 New Comment:

verified with PHP 4.3.1-dev..



Previous Comments:
------------------------------------------------------------------------

[2003-02-12 12:46:21] [EMAIL PROTECTED]

We're already discussing this - so reopening was valid.

------------------------------------------------------------------------

[2003-02-12 05:16:36] [EMAIL PROTECTED]

Re-open: at least with single three characters 'inf', this is a bug and
not a 'functionality'.

------------------------------------------------------------------------

[2003-02-12 04:38:17] [EMAIL PROTECTED]

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

------------------------------------------------------------------------

[2003-02-11 17:11:20] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

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-11 13:55:05] [EMAIL PROTECTED]

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

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22173&edit=1

Reply via email to