note 83257 rejected from language.oop5.static by felipe

From: Date: Mon, 19 May 2008 12:41:32 +0000
Subject: note 83257 rejected from language.oop5.static by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139522@lists.php.net to get a copy of this message
Note Submitter: admloki at gmail dot com ---- Whatta... As i founded, when calling a static class method into that class, PHP says that couldn't use $this when not in class, so: <?php final public class Test { private $vars = array(); public function __construct() {} //Let it empty public function setvalue($var,$value) { $this->vars[$var] = $value; //Adds a variable with value into an array } //HERE IT IS! public static function getvalue($var) { if(isset($this->vars[$var])) return $this->vars[$var]; } //Finally : public function doSome() { self::setvalue('foo','bar'); //Works fine self::getvalue('foo'); //Error! } ?> Is it a bug or something else?

« previous php.notes (#139522) next »