{"id":1858,"date":"2022-08-17T19:35:29","date_gmt":"2022-08-17T10:35:29","guid":{"rendered":"https:\/\/ani2life.com\/wp\/?p=1858"},"modified":"2022-08-17T19:42:14","modified_gmt":"2022-08-17T10:42:14","slug":"php-8-1%ec%97%90%ec%84%9c-%ec%83%81%ec%86%8d%eb%90%9c-%eb%a9%94%ec%84%9c%eb%93%9c%ec%97%90%ec%84%9c-%ec%a0%95%ec%a0%81-%eb%b3%80%ec%88%98-%ec%82%ac%ec%9a%a9-%eb%ac%b8%ec%a0%9c","status":"publish","type":"post","link":"https:\/\/ani2life.com\/wp\/?p=1858","title":{"rendered":"PHP 8.1\uc5d0\uc11c \uc0c1\uc18d\ub41c \uba54\uc11c\ub4dc\uc5d0\uc11c \uc815\uc801 \ubcc0\uc218 \uc0ac\uc6a9 \ubb38\uc81c"},"content":{"rendered":"<p>PHP 8.0\uc5d0\uc11c 8.1\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\uc911 <a href=\"https:\/\/www.php.net\/manual\/en\/migration81.incompatible.php#migration81.incompatible.core.static-variable-inheritance\">Usage of static Variables in Inherited Methods<\/a> \ubcc0\ud654\ub85c \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">class A_Class\r\n{\r\n    public static function foo()\r\n    {\r\n        static $num = 0;\r\n\r\n        return ++$num;\r\n    }\r\n}\r\n\r\nclass B_Class extends A_Class\r\n{\r\n}\r\n\r\necho A_Class::foo(); \/\/ \ucd9c\ub825 1\r\necho B_Class::foo(); \/\/ PHP 8.0: \ucd9c\ub825 1, PHP 8.1: \ucd9c\ub825 2<\/pre>\n<p>\uc704 \ucf54\ub4dc\uc5d0\uc11c \uc815\uc801 \ubcc0\uc218 $num\uc744 PHP 8.1\uc5d0\uc11c\ub294 \ubd80\ubaa8 \ud074\ub798\uc2a4\uc640 \uc790\uc2dd \ud074\ub798\uc2a4\uac00 \uc11c\ub85c \uacf5\uc720\ud55c\ub2e4.<\/p>\n<p>\uadf8\ub798\uc11c \uc544\ub798\uc758 \ucf54\ub4dc\uc640 \uac19\uc774 \uc815\uc801 \ubcc0\uc218\ub97c \ubc30\uc5f4\ub85c \ub9cc\ub4e4\uc5b4 \uac01 \ud074\ub798\uc2a4\ubcc4\ub85c \uac12\uc744 \uc800\uc7a5\ud558\ub3c4\ub85d \uc218\uc815\ud588\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">class A_Class\r\n{\r\n    public static function foo()\r\n    {\r\n        static $num_by_class = [];\r\n\r\n        $num_by_class[static::class] ??= 0;\r\n        $num = &amp;$num_by_class[static::class];\r\n\r\n        return ++$num;\r\n    }\r\n}\r\n\r\nclass B_Class extends A_Class\r\n{\r\n}\r\n\r\necho A_Class::foo();\r\necho B_Class::foo();<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP 8.0\uc5d0\uc11c 8.1\ub85c \ub9c8\uc774\uadf8\ub808\uc774\uc158\uc911 Usage of static Variables in Inherited Methods \ubcc0\ud654\ub85c \uc624\ub958\uac00 \ubc1c\uc0dd\ud588\ub2e4. class A_Class { public static function foo() { static $num = 0; return ++$num; } } class B_Class extends A_Class { } echo A_Class::foo(); \/\/ \ucd9c\ub825 1 echo B_Class::foo(); \/\/ PHP 8.0: \ucd9c\ub825 1, PHP 8.1: \ucd9c\ub825 2 \uc704 \ucf54\ub4dc\uc5d0\uc11c \uc815\uc801 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[152],"_links":{"self":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1858"}],"collection":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1858"}],"version-history":[{"count":4,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1858\/revisions"}],"predecessor-version":[{"id":1862,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1858\/revisions\/1862"}],"wp:attachment":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}