php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74363 echo doesn't accept multiple arguments
Submitted: 2017-04-02 12:49 UTC Modified: 2017-04-02 13:26 UTC
From: olafvdspek at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.6.30 OS: Debian
Private report: No CVE-ID: None
 [2017-04-02 12:49 UTC] olafvdspek at gmail dot com
Description:
------------
Echo doesn't appear to accept multiple arguments

PHP 5.6.30-0+deb8u1 (cli) (built: Feb  8 2017 08:50:21) 
PHP 7.0.16-3 (cli) (built: Feb 22 2017 10:03:06) ( NTS )

Test script:
---------------
<?php
echo('A', 'B');

Expected result:
----------------
AB

Actual result:
--------------
PHP Parse error:  syntax error, unexpected ',' in /root/a.php on line 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-02 12:53 UTC] olafvdspek at gmail dot com
Grr, this seems to simple to be true.

> Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.

> void echo ( string $arg1 [, string $... ] )

Perhaps this should be split into two lines, one without parentheses and with multiple arguments and one with parentheses and a single argument.

Or multiple arguments should be supported in both forms..
 [2017-04-02 13:01 UTC] dm@php.net
-Status: Open +Status: Not a bug
 [2017-04-02 13:01 UTC] dm@php.net
Not a bug, explained in manual as you've later realized.
 [2017-04-02 13:18 UTC] olafvdspek at gmail dot com
Could it be reclassified as feature request to allow echo to also accept multiple arguments when parentheses are used?

If not, IMO the documentation should be improved as explained in the previous comment.
 [2017-04-02 13:22 UTC] nikic@php.net
Echo and parenthesis have nothing to do with each other. You can write echo("Foo") in the same way you're allowed to write echo(((((((((("Foo")))))))))). Both are equally pointless. The correct echo syntax is `echo "Foo"`.
 [2017-04-02 13:26 UTC] olafvdspek at gmail dot com
@nikic, OK, perhaps the correct syntax could be used right below http://php.net/manual/en/function.echo.php#refsect1-function.echo-description then?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 06:01:30 2024 UTC