{"id":948,"date":"2023-06-18T19:01:29","date_gmt":"2023-06-18T10:01:29","guid":{"rendered":"https:\/\/shinke1987.net\/?p=948"},"modified":"2023-06-18T19:01:30","modified_gmt":"2023-06-18T10:01:30","slug":"%e9%81%85%e5%bb%b6%e9%9d%99%e7%9a%84%e6%9d%9f%e7%b8%9b","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=948","title":{"rendered":"\u9045\u5ef6\u9759\u7684\u675f\u7e1b"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u53c2\u8003Web\u30da\u30fc\u30b8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.php.net\/manual\/ja\/language.oop5.late-static-bindings.php\" data-type=\"URL\" data-id=\"https:\/\/www.php.net\/manual\/ja\/language.oop5.late-static-bindings.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP: \u9045\u5ef6\u9759\u7684\u675f\u7e1b (Late Static Bindings) &#8211; Manual<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.php.net\/manual\/ja\/function.get-called-class.php\" data-type=\"URL\" data-id=\"https:\/\/www.php.net\/manual\/ja\/function.get-called-class.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\uff1aget_called_class<\/a><\/li>\n<\/ul>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u6982\u8981<\/h2>\n\n\n\n<p>\u9045\u5ef6\u9759\u7684\u675f\u7e1b( Late Static Bindings )\u3068\u547c\u3070\u308c\u308b\u6a5f\u80fd\u304c\u3042\u308b\u3002<br>\u3053\u308c\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u9759\u7684\u7d99\u627f\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3067\u547c\u3073\u51fa\u3057\u5143\u306e\u30af\u30e9\u30b9\u3092\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u9045\u5ef6\u9759\u7684\u675f\u7e1b\u306f\u975e\u8ee2\u9001\u30b3\u30fc\u30eb\u306e\u30af\u30e9\u30b9\u540d\u3092\u4fdd\u5b58\u3059\u308b\u3089\u3057\u3044\u3002<br>static\u30e1\u30bd\u30c3\u30c9\u306e\u5834\u5408\u3001\u660e\u793a\u7684\u306b\u6307\u5b9a\u3055\u308c\u305f\u30af\u30e9\u30b9\u3068\u306a\u308b\u3002\uff08::\u6f14\u7b97\u5b50\u306e\u5de6\u5074\u306b\u66f8\u304b\u308c\u305f\u3082\u306e\uff09<br>static\u30e1\u30bd\u30c3\u30c9\u4ee5\u5916\u306e\u5834\u5408\u3001\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30af\u30e9\u30b9\u3068\u306a\u308b\u3002<\/p>\n\n\n\n<p>\u8ee2\u9001\u30b3\u30fc\u30eb\u3068\u306f\u3001selff:: \/ parent:: \/ static:: \u306b\u3088\u308b::\u6f14\u7b97\u5b50\u3092\u4f7f\u3063\u305f\u30b3\u30fc\u30eb\u306e\u3053\u3068\u3002<br>\uff08\u3042\u308b\u3044\u306f\u30af\u30e9\u30b9\u968e\u5c64\u306e\u4e2d\u3067\u306eforward_static_call()\u306b\u3088\u308b\u30b3\u30fc\u30eb\u306e\u3053\u3068\uff09<\/p>\n\n\n\n<p>get_called_class()\u95a2\u6570\u3092\u4f7f\u3046\u3068\u30b3\u30fc\u30eb\u5143\u306e\u30af\u30e9\u30b9\u540d\u3092\u6587\u5b57\u5217\u3067\u53d6\u5f97\u3067\u304d\u308b\u3002<br>static::\u306f\u3053\u306e\u30af\u30e9\u30b9\u306e\u30b9\u30b3\u30fc\u30d7\u3068\u306a\u308b\u3002<br>\uff08\u9045\u5ef6\u9759\u7684\u675f\u7e1b\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u89e3\u304f\u6642\u306b\u4f7f\u3048\u308b\u95a2\u6570\uff09<\/p>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u7c21\u6613\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\nclass A {\n    public static function who() {\n        echo &#039;A::who()_echo : &#039; . __CLASS__ . &quot;\\n&quot;;\n    }\n\n    public static function test() {\n        var_dump(&#039;A::test()_get_called_class : &#039; . get_called_class());\n        self::who();\n        static::who();\n    }\n}\n\nclass B extends A {\n    public static function who() {\n        var_dump(&#039;B::who()_get_called_class : &#039; . get_called_class());\n        echo &#039;B::who()_echo : &#039; . __CLASS__;\n    }\n}\n\nB::test();\n<\/pre><\/div>\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d\u30b3\u30fc\u30c9\u306e\u7d50\u679c<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nstring(30) &quot;A::test()_get_called_class : B&quot;\nA::who()_echo : A\nstring(29) &quot;B::who()_get_called_class : B&quot;\nB::who()_echo : B\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003Web\u30da\u30fc\u30b8 \u6982\u8981 \u9045\u5ef6\u9759\u7684\u675f\u7e1b( Late Static Bindings )\u3068\u547c\u3070\u308c\u308b\u6a5f\u80fd\u304c\u3042\u308b\u3002\u3053\u308c\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u9759\u7684\u7d99\u627f\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3067\u547c\u3073\u51fa\u3057\u5143\u306e\u30af\u30e9\u30b9\u3092\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002 \u9045\u5ef6\u9759\u7684\u675f\u7e1b\u306f\u975e\u8ee2\u9001\u30b3\u30fc\u30eb\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[81],"class_list":["post-948","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=948"}],"version-history":[{"count":1,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions"}],"predecessor-version":[{"id":949,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions\/949"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}