note 104823 added to language.oop5.static
| From: | payal001 at gmail dot com | Date: | Sat, 09 Jul 2011 10:17:05 +0000 |
| Subject: | note 104823 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181372@lists.php.net to get a copy of this message | ||
Here statically accessed property prefer property of the class for which it is called. Where as self
keyword enforces use of current class only. Refer the below example:
<?php
class a{
static protected $test="class a";
public function static_test(){
echo static::$test; // Results class b
echo self::$test; // Results class a
}
}
class b extends a{
static protected $test="class b";
}
$obj = new b();
$obj->static_test();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 202.137.250.3
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/104823
Del: integrated -- https://master.php.net/note/delete/104823/integrated
Del: useless -- https://master.php.net/note/delete/104823/useless
Del: bad code -- https://master.php.net/note/delete/104823/bad+code
Del: spam -- https://master.php.net/note/delete/104823/spam
Del: non-english -- https://master.php.net/note/delete/104823/non-english
Del: in docs -- https://master.php.net/note/delete/104823/in+docs
Del: other reasons-- https://master.php.net/note/delete/104823
Reject -- https://master.php.net/note/reject/104823
Search -- https://master.php.net/manage/user-notes.php