#19439 [NEW]: reference to $this issue warning

From: Date: Mon, 16 Sep 2002 17:59:08 +0000
Subject: #19439 [NEW]: reference to $this issue warning
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19479@lists.php.net to get a copy of this message
From: kylam@superapple.org Operating system: Windows 2000 PHP version: 4.2.3 PHP Bug Type: Class/Object related Bug description: reference to $this issue warning 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 bug report at http://bugs.php.net/?id=19439&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19439&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19439&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19439&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19439&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19439&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19439&r=support Expected behavior: http://bugs.php.net/fix.php?id=19439&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19439&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19439&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19439&r=globals

« previous php.bugs (#19479) next »