|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78568 Incorrect evaluation of ?? and ? containing expression
Submitted: 2019-09-19 16:30 UTC Modified: 2019-09-19 16:34 UTC
From: carlos at wfmh dot org dot pl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.3.9 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: carlos at wfmh dot org dot pl
New email:
PHP Version: OS:


 [2019-09-19 16:30 UTC] carlos at wfmh dot org dot pl
Incorrect evaluation of ?? and ? containing expression.

This code produces incorrect results:

$result = 20;
$success = false;

$result = $result ?? $success ? "TRUE" : "FALSE";

would output "TRUE" instead of expected 20.

Workaround is to put ternary into brackets:

$result = 20;
$success = false;

$result = $result ?? ($success ? "TRUE" : "FALSE");

and then the result is as expected 20.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-19 16:34 UTC]
-Status: Open +Status: Not a bug
 [2019-09-19 16:34 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at
?? has higher precedence than ?:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 05:01:24 2021 UTC