selfの場合、親にしかないメソッド呼んだときは親の定数が使われる。 staticの場合、親にしかないメソッドでも子の方が採用。 <?php class OYA { const TEST = '親'; public function getSelfOverride() { return self::TEST; } public function getSelfOya() { return self::TEST; } public function getStaticOverride() { return static::TEST; } public function getStaticOya() { return static::TEST; } } class KO extends OYA { const TEST = '子'; public function getSelfOverrid
![PHPの親クラスと子クラスに同じ定数(const)があった時のselfとstaticの違い。 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/5e2128142c76064a468c95f8dfd420dbc96378af/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-9f5428127621718a910c8b63951390ad.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTkxNiZ0eHQ9UEhQJUUzJTgxJUFFJUU4JUE2JUFBJUUzJTgyJUFGJUUzJTgzJUE5JUUzJTgyJUI5JUUzJTgxJUE4JUU1JUFEJTkwJUUzJTgyJUFGJUUzJTgzJUE5JUUzJTgyJUI5JUUzJTgxJUFCJUU1JTkwJThDJUUzJTgxJTk4JUU1JUFFJTlBJUU2JTk1JUIwJTI4Y29uc3QlMjklRTMlODElOEMlRTMlODElODIlRTMlODElQTMlRTMlODElOUYlRTYlOTklODIlRTMlODElQUVzZWxmJUUzJTgxJUE4c3RhdGljJUUzJTgxJUFFJUU5JTgxJTk1JUUzJTgxJTg0JUUzJTgwJTgyJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmdHh0LWNsaXA9ZWxsaXBzaXMmdHh0LWFsaWduPWxlZnQlMkN0b3Amcz1hNzg2Nzk0NWI5NDc0YjBkYWQyZjBjNmNlYTc0OGExOQ%26mark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