ID: 35865
Updated by: [EMAIL PROTECTED]
Reported By: tigerincanada at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: Documentation problem
Operating System: Linux 2.4.20 (Red Hat)
PHP Version: 4.4.1
New Comment:
I don't get it. What exactly are you expecting to document?
Previous Comments:
------------------------------------------------------------------------
[2006-01-01 02:36:48] tigerincanada at gmail dot com
Description:
------------
After upgrading to PHP 4.4.1 I started seeing "Fatal error: Call to a
member function on a non-object" where previously there had been none.
It appears that the behaviour of references has changed, so the the
reuse of a variable name no longer unassigns that variable name from
earlier copies of the previous contents of that variable.
The attempt at a reproduce code below doesn't actually cause the bug to
reproduce, but illustrates the type of code that was causing the
problem. I haven't worked out what feature of my more complex
production code is causing the issue, but it wasn't there before
upgrading to from 4.3.11 to 4.4.1.
Googling "Fatal error: Call to a member function on a non-object PHP
4.4.1" shows up a few other people who appear to have run into a
similar unexpected issue.
Reproduce code:
---------------
Class Foo
{
var $name;
function Foo($n) {
$this->name = $n;
}
function getName() {
return $this->name;
}
}
$result =& new Foo("First");
$c =& $result;
$b = "Second";
$result =& $b;
print $c->getName();
Expected result:
----------------
"First"
Actual result:
--------------
Attempted reproduce code: "First"
Production code: "Fatal error: Call to a member function on a
non-object"
In production, querying the zval of $c finds that it has somehow been
set to the value of on the the object's properties... major
head-scratcher!
When I changed the code to remove the variable re-use, like this:
$c =& new Foo("First");
$b = "Second";
$result =& $b;
The problem went away...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35865&edit=1