php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26484 "Returning References" could do with more info
Submitted: 2003-12-01 06:22 UTC Modified: 2004-08-06 23:32 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: sdavey at datalink dot net dot au Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.3.2 OS: NA
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: sdavey at datalink dot net dot au
New email:
PHP Version: OS:

 

 [2003-12-01 06:22 UTC] sdavey at datalink dot net dot au
Description:
------------
The Returning References manual page contains the following comment:

"Note:  Unlike parameter passing, here you have to use & in both places - to indicate that you return by-reference, not a copy as usual, and to indicate that reference binding, rather than usual assignment, should be done for $foo."

It refers to pass-by-reference, where you have to use the ampersand in both the function *and* in the assignment of the function value to a variable.

It is not clear what would happen if you didn't put the ampersand in both places, and it would be nice to have someone explain this.

I'm a fairly seasoned PHP developer, but references are complex, and judging by the user comments in various places in the manual concerning them I think it would be great to have a sentance or two clarify this.

I know it's only a minor request, but for developers seeking to fine-tune their code, understanding references is clearly the way to go.

Thanks, Scott.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-06 23:32 UTC] vrana@php.net
It's illegal to omit one or the other & thus there is "you have to use & in both places". In current PHP versions (4.3.8, 5.0.0) it seems that & in function declaration is informative only but it can change in the future.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 00:01:36 2025 UTC