note 117909 added to language.oop5.late-static-bindings
| From: | sskaje at gmail dot com | Date: | Mon, 31 Aug 2015 04:01:58 +0000 |
| Subject: | note 117909 added to language.oop5.late-static-bindings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203526@lists.php.net to get a copy of this message | ||
static::class and self::class can be used to get current class name,
work under 5.5 and 5.6
failed in 5.3.
<?php
class a{
function d() {
echo "=== self::class ===\n";
var_dump(self::class);
echo "=== static::class ===\n";
var_dump(static::class);
}
}
class b extends a{}
class c extends b{}
a::d();
b::d();
c::d();
/*
Output:
=== self::class ===
string(1) "a"
=== static::class ===
string(1) "a"
=== self::class ===
string(1) "a"
=== static::class ===
string(1) "b"
=== self::class ===
string(1) "a"
=== static::class ===
string(1) "c"
*/
----
Server IP: 72.52.91.14
Probable Submitter: 114.254.116.202
----
Manual Page -- http://php.net/manual/en/language.oop5.late-static-bindings.php
Edit -- https://master.php.net/note/edit/117909
Del: integrated -- https://master.php.net/note/delete/117909/integrated
Del: useless -- https://master.php.net/note/delete/117909/useless
Del: bad code -- https://master.php.net/note/delete/117909/bad+code
Del: spam -- https://master.php.net/note/delete/117909/spam
Del: non-english -- https://master.php.net/note/delete/117909/non-english
Del: in docs -- https://master.php.net/note/delete/117909/in+docs
Del: other reasons-- https://master.php.net/note/delete/117909
Reject -- https://master.php.net/note/reject/117909
Search -- https://master.php.net/manage/user-notes.php