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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 - 21 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC