note 83257 added to language.oop5.static

From: Date: Fri, 16 May 2008 23:50:33 +0000
Subject: note 83257 added to language.oop5.static
Groups: php.notes 
Request: Send a blank email to php-notes+get-139461@lists.php.net to get a copy of this message
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? ---- Server IP: 195.54.192.44 Probable Submitter: 127.0.0.1 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.static.php Edit -- https://master.php.net/note/edit/83257 Del: integrated -- https://master.php.net/note/delete/83257/integrated Del: useless -- https://master.php.net/note/delete/83257/useless Del: bad code -- https://master.php.net/note/delete/83257/bad+code Del: spam -- https://master.php.net/note/delete/83257/spam Del: non-english -- https://master.php.net/note/delete/83257/non-english Del: in docs -- https://master.php.net/note/delete/83257/in+docs Del: other reasons-- https://master.php.net/note/delete/83257 Reject -- https://master.php.net/note/reject/83257 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139461) next »