mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Update php-ru.html.markdown
This commit is contained in:
parent
6e7c5c7933
commit
e5d87c93a3
@ -687,45 +687,6 @@ use My\Namespace as SomeOtherNamespace;
|
||||
|
||||
$cls = new SomeOtherNamespace\MyClass();
|
||||
|
||||
*//**********************
|
||||
* Позднее статическое связывание.
|
||||
*
|
||||
*/
|
||||
|
||||
class ParentClass
|
||||
{
|
||||
public static function who()
|
||||
{
|
||||
echo "I'm a " . __CLASS__ . "\n";
|
||||
}
|
||||
|
||||
public static function test()
|
||||
{
|
||||
// self ссылается на класс в котором определен метод.
|
||||
self::who();
|
||||
// static ссылается на класс в котором метод вызван.
|
||||
static::who();
|
||||
}
|
||||
}
|
||||
|
||||
ParentClass::test();
|
||||
/*
|
||||
I'm a ParentClass
|
||||
I'm a ParentClass
|
||||
*/
|
||||
|
||||
class ChildClass extends ParentClass
|
||||
{
|
||||
public static function who()
|
||||
{
|
||||
echo "But I'm " . __CLASS__ . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
ChildClass::test();
|
||||
/*
|
||||
I'm a ParentClass
|
||||
But I'm ChildClass
|
||||
|
||||
/**********************
|
||||
* Позднее статическое связывание.
|
||||
|
Loading…
Reference in New Issue
Block a user