|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81329 echo misbehaves when there is a ternary operator
Submitted: 2021-08-04 01:29 UTC Modified: 2021-08-04 04:08 UTC
From: chris at candm dot org dot uk Assigned:
Status: Not a bug Package: Strings related
PHP Version: 7.4.22 OS: Linux Mint 20 Apache 2.4.1
Private report: No CVE-ID: None
 [2021-08-04 01:29 UTC] chris at candm dot org dot uk
When using echo, if a ternary is concatenated after a string, the string is not echoed, only the result from the ternary.

PHP version 7.4.3
Apache Version	Apache/2.4.41 (Ubuntu)
Apache API Version	20120211
Linux Kernel: 5.8.0-63-generic x86_64 bits: 64 
Desktop: Cinnamon 4.8.6 
Linux Mint 20.1 Ulyssa base: Ubuntu 20.04
Machine: Acer Aspire A515-55 v: V1.08

Test script:
echo "THIS SHOULD SHOW ".(true)?'true':'false';

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-04 04:08 UTC]
-Status: Open +Status: Not a bug
 [2021-08-04 04:08 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
The concatenation '.' operator has higher precedence than the ternary ? : operator.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 07:01:30 2024 UTC