Bug #76414 [Nab]: return echo("foo"); ought to work as expected
| From: | aleemb at gmail dot com | Date: | Tue, 05 Jun 2018 11:36:30 +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-215500@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
User updated by: aleemb at gmail dot com
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:
I was assuming since neither are language constructs, they could share the same "return"
semantics. Your explanation, however, helps clarify that. Thanks for taking the time to highlight
it, learnt something new.
Previous Comments:
------------------------------------------------------------------------
[2018-06-05 11:36:01] yohgaki@php.net
Since echo is not a function, you cannot do
$var ? echo 'abc' : echo 'xyz';
also. It's not a function, so echo wouldn't return absolutely nothing. Therefore, it
cannot be used anywhere expression is expected.
------------------------------------------------------------------------
[2018-06-05 11:31:06] requinix@php.net
> 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.
------------------------------------------------------------------------
[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().
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=76414
--
Edit this bug report at https://bugs.php.net/bug.php?id=76414&edit=1