note 75274 added to language.oop5
| From: | Mino at osu1 dot php dot net | Date: | Mon, 21 May 2007 17:41:48 +0000 |
| Subject: | note 75274 added to language.oop5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126802@lists.php.net to get a copy of this message | ||
I've tested some abstract classes with static variable. I hope, you can use it too. ;)
abstract class test {
public static $test = 1;
public function get() {
return self::$test;
}
}
class test2 extends test {
public static $test = 2;
public function get() {
return self::$test;
}
public function getParent() {
return parent::$test;
}
public function getParent2() {
return parent::get();
}
}
$test = new test2();
echo $test->get()."<br>";
echo test2::get()."<br>";
echo test::get()."<br>";
echo $test->getParent()."<br>";
echo $test->getParent2()."<br>";
// output
// 2
// 2
// 1
// 1
// 1
----
Server IP: 69.147.83.197
Probable Submitter: 62.226.28.196
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- https://master.php.net/note/edit/75274
Del: integrated -- https://master.php.net/note/delete/75274/integrated
Del: useless -- https://master.php.net/note/delete/75274/useless
Del: bad code -- https://master.php.net/note/delete/75274/bad+code
Del: spam -- https://master.php.net/note/delete/75274/spam
Del: non-english -- https://master.php.net/note/delete/75274/non-english
Del: in docs -- https://master.php.net/note/delete/75274/in+docs
Del: other reasons-- https://master.php.net/note/delete/75274
Reject -- https://master.php.net/note/reject/75274
Search -- https://master.php.net/manage/user-notes.php