#19439 [Opn->Fbk]: reference to $this issue warning
| From: | sniper@php.net | Date: | Sun, 08 Dec 2002 16:52:00 +0000 |
| Subject: | #19439 [Opn->Fbk]: reference to $this issue warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27060@lists.php.net to get a copy of this message | ||
ID: 19439
Updated by: sniper@php.net
Reported By: kylam@superapple.org
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Windows 2000
PHP Version: 4.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
Can't reproduce with PHP 4.3.0-dev. Although I might have misunderstood
what script actually is causing it. If it still happens with the latest
snapshot, please include a really NOT working example script here.
Previous Comments:
------------------------------------------------------------------------
[2002-09-16 12:59:08] kylam@superapple.org
Here are two classes:
<?php
class myBase
{
function g()
{
return 'haha';
}
function output()
{
$x = new myBar($this);
echo $this->g();
}
}
class myBar
{
var $container;
function myBar(&$obj)
{
$this->container = $obj;
}
}
// this work
echo myBase::g();
?>
But when I copy the code of myBase::output() method outside the class
defination, without changing the reference to $this variable passed to
'$x = new myBar($this)' carelessly, that is
<?php
$x = new myBar($this);
echo myBase::g(); // this issue warning
?>
PHP gives a message to me:
Warning: Problem with method call - please report this bug in xxx on
line xx
It should not be a normal case to work with $this outside a class, but
as the message 'define' this as a bug, I just drop a message here.
:)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19439&edit=1