note 129163 added to language.oop5.paamayim-nekudotayim
| From: | gazianis2200 at gmail dot com | Date: | Mon, 15 Jan 2024 14:43:32 +0000 |
| Subject: | note 129163 added to language.oop5.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221117@lists.php.net to get a copy of this message | ||
<?php
/**
*access a constant from outside a class
*/
class Foo{
public const A = "Constant A";
}
echo Foo::A;
echo "\n";
/**
*access a constant within its own class
*/
class Bar{
public const A = "Constant A";
public function abc(){
echo self::A;
echo "\n";
}
}
$obj = new Bar;
$obj->abc();
/**
*access a constant within her child class
*/
class Baz extends Bar{
public function abc(){
echo parent::A;
}
}
$obj = new Baz;
$obj->abc();
//Static property and static method also follows this principle.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 103.120.33.26)
----
Manual Page -- https://php.net/manual/en/language.oop5.paamayim-nekudotayim.php
Edit -- https://main.php.net/note/edit/129163
Del: integrated -- https://main.php.net/note/delete/129163/integrated
Del: useless -- https://main.php.net/note/delete/129163/useless
Del: bad code -- https://main.php.net/note/delete/129163/bad+code
Del: spam -- https://main.php.net/note/delete/129163/spam
Del: non-english -- https://main.php.net/note/delete/129163/non-english
Del: in docs -- https://main.php.net/note/delete/129163/in+docs
Del: other reasons-- https://main.php.net/note/delete/129163
Reject -- https://main.php.net/note/reject/129163
Search -- https://main.php.net/manage/user-notes.php