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
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: 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 08:00:01 2026 UTC