ID: 29877 User updated by: bharat at menalto dot com Reported By: bharat at menalto dot com Status: Open Bug Type: Documentation problem Operating System: FreeBSD 4.8 PHP Version: 4CVS, 5CVS (2004-12-10) New Comment:
Jani, I appreciate that this behaviour hasn't changed in a while. If it's part of the language, I'm ok with it. However, in the documentation that I referenced, it clearly states: --- 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. --- But as my sample code indicates (unless you can demonstrate a bug in my code), the & is not required on the function. So if this is the desired behaviour, then let us please update the documentation to state that it is NOT required that there be an & on the function for you to get back a reference. Either way we resolve this, there's a discrepancy that should be removed. Thanks! Previous Comments: ------------------------------------------------------------------------ [2004-12-12 16:29:31] [EMAIL PROTECTED] Note: Tested with 4.2.2 and it works exactly the same. IMO this is not a bug. ------------------------------------------------------------------------ [2004-08-28 22:56:41] bharat at menalto dot com Description: ------------ According to the documentation here: http://us4.php.net/manual/en/language.references.return.php In order to assign a variable as a reference to a value returned by a class method, the method needs to also return by reference. However, on PHP 4.3.8 in my test script I've found that the semantics are the same whether or not you return by reference. This is surprising to me. I could have sworn that it didn't used to be this way. Please let me know if you need more information. I can reproduce this with a stock php.ini. If this is the desired behaviour in this case, then we should update the documentation to reflect that the ampersand is no longer necessary on the getter method. Reproduce code: --------------- http://www.menalto.com/.outgoing/php/ref.php Expected result: ---------------- The URL above indicates the expected results. I can elaborate if necessary. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29877&edit=1