[php-src] Issue #7750: string '0.0' evaluated to true
| From: | noreply@php.net | Date: | Fri, 10 Dec 2021 15:52:31 +0000 |
| Subject: | [php-src] Issue #7750: string '0.0' evaluated to true | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238317@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7750
Author: richirm77
### Description
Surely this is not a mistake, but I do not understand why it is so.
Consider the following code:
```php
if (0) echo "int 0 is true" . "\n";
if ('0') echo "string '0' is true" . "\n";
if (0.0) echo "float 0.0 is true" . "\n";
if ('0.0') echo "string '0.0' is true" . "\n";
```
Why does the string '0.0' evaluate to true, when its logical value would be false? The
string '0' evaluates to false. Why is the same not true for '0.0'?
https://3v4l.org/ZNhbM
### PHP Version
PHP 7.X, 8.X
### Operating System
_No response_