Error in current documentation or PHP bug?
| From: | Indira Virk | Date: | Thu, 09 May 2002 09:40:46 +0000 |
| Subject: | Error in current documentation or PHP bug? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-96785@lists.php.net to get a copy of this message | ||
Hi.
This is regarding section 'Strings' under the section 'Types' in the manual.
Under 'String Conversion' it says:
When the first expression is a string, the type of the variable will depend on the second
expression.
$foo = "10.0 pigs " + 1; // $foo is integer
(11)
$foo = "10.0 pigs " + 1.0; // $foo is float (11)
For more information on this conversion, see the Unix manual page for strtod(3).
If you would like to test any of the examples in this section, you can cut and paste the examples
and insert the following line to see for yourself what's going on:
echo "\$foo==$foo; type is " . gettype ($foo) .
"<br>\n";
I tried the above example:
<?php
$foo = "10.0 pigs " + 1;
if (is_float($foo)) {
echo "Value: (float)$foo<BR>";
} else if (is_int($foo)) {
echo "Value: (int)$foo<BR>";
}
echo "\$foo==$foo; type is " . gettype ($foo) .
"<br>\n";
?>
The output is:
Value: (float)11
$foo==11; type is double
According to the documentation $foo should be of type 'integer'.
Is this an error in the documentation or a PHP bug?
I have PHP 4.2.0 installed as a static module in Apache 1.3.19 in HP-UX 11.0.
Regards,
Indira.