note 73306 deleted from language.oop5.static by colder

From: Date: Sat, 17 Feb 2007 01:13:12 +0000
Subject: note 73306 deleted from language.oop5.static by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123501@lists.php.net to get a copy of this message
Note Submitter: Ionut Matei Reason: in docs ---- because when you call a method statically, outside of the class, you cannot access $this, not even indirectly: <?php class c { static $v = 'value'; function get_v() { return self::$v; } function get2() { return $this->v; } function doit() { echo 'self is ' . self::get_v() . '<br>'; echo 'this is ' . $this->get_v() . '<br>'; } } $o = new c; echo '<br><b>non-static func:</b><br>'; $o->doit(); echo '<br><b>static func:</b><br>'; c::doit(); ?> gives this: non-static func: self is value this is value static func: self is value Fatal error: Using $this when not in object context in [...]

« previous php.notes (#123501) next »