[php-src] Issue #20958: `??` in if () statement misbehaving

From: Date: Sat, 17 Jan 2026 12:07:35 +0000
Subject: [php-src] Issue #20958: `??` in if () statement misbehaving
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251555@lists.php.net to get a copy of this message
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

« previous php.bugs (#251555) next »