|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-23 11:19 UTC] php at koert dot bitfactory dot nl
Description:
------------
If a static method is called from an objectcontext, $this is accessible from that objectcontext.
$this should be out of scop in the static method...
Reproduce code:
---------------
class static_class {
function static_func() { echo $this->variable; }
}
class testclass {
function func() { static_class::static_func(); }
}
$x = new testclass();
$x->func();
Expected result:
----------------
<br />
<b>Fatal error</b>: Using $this when not in object context in <b>[filename]</b> on line <b>2</b><br />
Actual result:
--------------
No output (thus no error)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 14:00:01 2025 UTC |
Still not fixed, it produces the wrong error. It should warn about $this, not about $variable. I am cvsupping as we speak, but i assume thie following testcase still doesn't produce an error: class static_class { var $variable="Variable in static_class."; function static_func() { echo $this->variable; } } class testclass { var $variable="Variable in testclass."; function func() { static_class::static_func(); } } $x = new testclass(); $x->func();static function static_func() { echo $this->variable; }