php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72865 describe difference to echo (with example ideally)
Submitted: 2016-08-17 12:48 UTC Modified: 2016-08-17 13:52 UTC
From: flashfee at gmx dot net Assigned: cmb (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: flashfee at gmx dot net
New email:
PHP Version: OS:

 

 [2016-08-17 12:48 UTC] flashfee at gmx dot net
Description:
------------
---
From manual page: http://www.php.net/function.print
---

Both echo and print output a string. 

The similiarity and differences should be described.
 (syntax, performance, buffering, alias ..???)

I use 'print' when I'm programming in Perl, I use echo when programming in PHP.
Now I learned there is also 'print' in PHP? So can I just forget 'echo' and always use print? :-)




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-17 13:44 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-08-17 13:44 UTC] cmb@php.net
The only relevant difference is that `print` accepts only one
argument, while `echo` accepts a comma separated list of
arguments.

As of PHP 7.0.0 both statements compile to the same opcode, namely
ZEND_ECHO, see <https://3v4l.org/lncp9/vld#output>. Formerly, they
had different opcodes (ZEND_ECHO and ZEND_PRINT), but ZEND_PRINT
forwarded to ZEND_ECHO, which might have made `print` slightly
slower.
 [2016-08-17 13:51 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339895
Log: Fix #72865: describe difference to echo (with example ideally)
 [2016-08-17 13:52 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2016-08-17 13:52 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=5acb71cfab3b71a44b752afaabdfa785f1776c20
Log: Fix #72865: describe difference to echo (with example ideally)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 04:00:01 2026 UTC