ID: 25220 Updated by: [EMAIL PROTECTED] Reported By: php at koert dot bitfactory dot nl Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Cygwin/win2k PHP Version: 5CVS-2003-08-23 (dev) New Comment:
static function static_func() { echo $this->variable; } Previous Comments: ------------------------------------------------------------------------ [2003-12-01 03:35:53] [EMAIL PROTECTED] You need to use 'static' in the function declaration to make it work like you expect. (otherwise it behaves like in PHP4..) ------------------------------------------------------------------------ [2003-11-29 07:11:24] php at koert dot bitfactory dot nl 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(); ------------------------------------------------------------------------ [2003-11-28 20:46:25] [EMAIL PROTECTED] Output with latest CVS: PHP Notice: Undefined property: testclass::$variable in /home/jani/t.php on line 4 ------------------------------------------------------------------------ [2003-08-23 11:19:11] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25220&edit=1