php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46606 Returning by Reference Increases Performance
Submitted: 2008-11-18 22:36 UTC Modified: 2008-11-28 23:03 UTC
From: php at info-svc dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at info-svc dot com
New email:
PHP Version: OS:

 

 [2008-11-18 22:36 UTC] php at info-svc dot com
Description:
------------
I'm reporting a documentation comment that was rejected but should be valid.

note 87076 rejected and deleted from language.references.return by notes editor danbrown

----- Copy of your note below -----

"Do not use return-by-reference to increase performance"

This is not accurate.  If you want PHP to return a string that was passed-by-reference without making a copy of it then you must also return-by-reference to increase performance.

Robert Chapin
Chapin Information Services

Reproduce code:
---------------
$a = 'world';
$b = escape($a);
$b .= '3';
echo $a;

function escape(&$hello) {
  $hello .= '2';
  return $hello;
}

Expected result:
----------------
world23

Actual result:
--------------
world2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-28 23:03 UTC] danbrown@php.net
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


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 12:00:01 2026 UTC