Bug #81329 [Opn->Nab]: echo misbehaves when there is a ternary operator
| From: | requinix@php.net | Date: | Wed, 04 Aug 2021 04:08:07 +0000 |
| Subject: | Bug #81329 [Opn->Nab]: echo misbehaves when there is a ternary operator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235583@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81329&edit=1
ID: 81329
Updated by: requinix@php.net
Reported by: chris at candm dot org dot uk
Summary: echo misbehaves when there is a ternary operator
-Status: Open
+Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Linux Mint 20 Apache 2.4.1
PHP Version: 7.4.22
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
https://www.php.net/manual/en/language.operators.precedence.php
The concatenation '.' operator has higher precedence than the ternary ? : operator.
Previous Comments:
------------------------------------------------------------------------
[2021-08-04 01:29:10] chris at candm dot org dot uk
Description:
------------
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:
---------------
<?php
echo "THIS SHOULD SHOW ".(true)?'true':'false';
Expected result:
----------------
Result:
THIS SHOULD SHOW true
Actual result:
--------------
Result
true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81329&edit=1