Bug #76414 [Nab]: return echo("foo"); ought to work as expected
| From: | requinix@php.net | Date: | Tue, 05 Jun 2018 11:31:07 +0000 |
| Subject: | Bug #76414 [Nab]: return echo("foo"); ought to work as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215498@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76414&edit=1
ID: 76414
Updated by: requinix@php.net
Reported by: aleemb at gmail dot com
Summary: return echo("foo"); ought to work as expected
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: OSX
PHP Version: 7.2.6
Block user comment: N
Private report: N
New Comment:
> is there any reason echo can't be tweaked to behave in the same manner?
Because there's no reason to? echo and print are both doing exactly what they're intended
to do.
Previous Comments:
------------------------------------------------------------------------
[2018-06-05 11:20:57] spam2 at rhsoft dot net
echo is *not* a function - it's a language costruct
echo $a, "\n", $b, "\n";
this would not be possible with a function and the difference is that is saves a ton of concat calls
compared to echo $a. "\n" . $b . "\n" which does exactly the same but becaus
eof the repeatet concat a ton of in-memory-copies a triggered which can be expensive depending on
the string sizes
------------------------------------------------------------------------
[2018-06-05 11:16:16] aleemb at gmail dot com
@requinix, is there any reason echo can't be tweaked to behave in the same manner?
------------------------------------------------------------------------
[2018-06-05 10:32:39] requinix@php.net
Use print().
------------------------------------------------------------------------
[2018-06-05 10:30:22] aleemb at gmail dot com
Description:
------------
This is either a bug or a feature request, either way the following should work as expected:
return echo("foo");
It should echo "foo" and return.
Test script:
---------------
return echo("foo");
Expected result:
----------------
foo
Actual result:
--------------
PHP Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ';'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76414&edit=1