mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-06 14:56:54 +02:00
Merge pull request #2815 from pofigizm/patch-1
[php/ru] delete repetition
This commit is contained in:
committed by
GitHub
commit
abed0ba3ec
@@ -687,45 +687,6 @@ use My\Namespace as SomeOtherNamespace;
|
|||||||
|
|
||||||
$cls = new SomeOtherNamespace\MyClass();
|
$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
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* Позднее статическое связывание.
|
* Позднее статическое связывание.
|
||||||
|
Reference in New Issue
Block a user