[php-src] Issue #20958: `??` in if () statement misbehaving
[email protected] (bludwagon)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
Issue: https://github.com/php/php-src/issues/20958
Author: bludwagon
### Description
The following code:
```php
<?php
$a=['t'=>'92345'];
var_dump($a['t']??0);// string(5) "92345"
var_dump('92345' < '12345');// false
if ($a['t']??0 < '12345'){echo('y');}else{echo('n');}// expected 'n' because ('92345' < '12345') <--- THIS
if ($a['x']??0 < '12345'){echo('y');}else{echo('n');}// expected 'y' because $a['x'] is null, so (0 < '12345')
```
Resulted in this output:
```
The ` <--- THIS` line returns 'y'
```
But I expected this output instead:
```
The ` <--- THIS` line returns 'n'
```
### PHP Version
```plain
PHP 8.4.16 (cli) (built: Dec 18 2025 21:19:25) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.16, Copyright (c) Zend Technologies
with Zend OPcache v8.4.16, Copyright (c), by Zend Technologies
```
### Operating System
Debian