{"id":1903,"date":"2024-05-01T16:44:17","date_gmt":"2024-05-01T07:44:17","guid":{"rendered":"https:\/\/ani2life.com\/wp\/?p=1903"},"modified":"2024-05-01T16:44:17","modified_gmt":"2024-05-01T07:44:17","slug":"php%eb%a1%9c-%eb%a7%8c%eb%93%a0-html-%ec%bd%94%eb%93%9c-%ec%b5%9c%ec%86%8c%ed%99%94-%ed%95%a8%ec%88%98","status":"publish","type":"post","link":"https:\/\/ani2life.com\/wp\/?p=1903","title":{"rendered":"PHP\ub85c \ub9cc\ub4e0 HTML \ucf54\ub4dc \ucd5c\uc18c\ud654 \ud568\uc218"},"content":{"rendered":"<p>HTML \ucf54\ub4dc \ucd5c\uc18c\ud654(minify)\uc6a9\uc73c\ub85c wyrihaximus\/html-compress \ud328\ud0a4\uc9c0\ub97c \uc0ac\uc6a9\ud558\uace0 \uc788\uc5c8\ub294\ub370 PHP 8.3\uc5d0\uc11c TypeError\uac00 \ubc1c\uc0dd\ud588\ub2e4. \uc774\ubbf8 \uc791\ub144 12\uc6d4\uc5d0 \ubc84\uadf8 \ud328\uce58 PR\uc774 \uc62c\ub77c\uc640 \uc788\uc74c\uc5d0\ub3c4 \uc218\uac1c\uc6d4\uac04 \uc544\ubb34\ub7f0 \uc751\ub2f5\uc774 \uc5c6\ub2e4. (<a href=\"https:\/\/github.com\/voku\/HtmlMin\/issues\/93\" target=\"_blank\" rel=\"noopener\">Uncaught TypeError with PHP 8.3 and id attribute<\/a>)<\/p>\n<p>\uc0c8\ub85c\uc6b4 \ubc84\uc804\uc774 \ubc30\ud3ec\ub420 \uac83\uc774\ub77c\ub294 \uae30\ub300\ub97c \ubc84\ub9ac\uace0 \ub2e4\ub978 \ud328\ud0a4\uc9c0\ub4e4\uc744 \ucc3e\uc544\ubd24\uc9c0\ub9cc \ub9c8\ub545\ud55c \uac83\uc744 \ucc3e\uc9c0 \ubabb\ud588\ub2e4. \uadf8\ub798\uc11c \uc9c1\uc811 \uad6c\ud604\ud558\uae30\ub85c \ud588\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\/**\r\n * DOM Document minify\r\n *\r\n * @param \\DOMDocument $doc\r\n * @return void\r\n *\/\r\nfunction minifyDOMDocument(\\DOMDocument $doc): void\r\n{\r\n    $xpath = new \\DOMXPath($doc);\r\n\r\n    {\r\n        $nodes = $xpath-&gt;query('\/\/comment()');\r\n        foreach ($nodes as $node) {\r\n            $node-&gt;parentNode-&gt;removeChild($node);\r\n        }\r\n    }\r\n\r\n    {\r\n        $nodes = $xpath-&gt;query('\/\/text()');\r\n        foreach ($nodes as $node) {\r\n            if ($node-&gt;nodeType === XML_CDATA_SECTION_NODE) {\r\n                $node-&gt;nodeValue = preg_replace('\/^\\s+|\\s+$\/m', '', $node-&gt;nodeValue);\r\n            } else {\r\n                $value = preg_replace('\/\\s+\/', ' ', $node-&gt;nodeValue);\r\n                $node-&gt;nodeValue = $value;\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\uc8fc\uc11d \ub178\ub4dc \uc9c0\uc6b0\uae30, CSS\ub098 JS \ucf54\ub4dc\uc758 \uc55e\ub4a4 \uacf5\ubc31 \uc81c\uac70, \ud14d\uc2a4\ud2b8 \ub178\ub4dc\uc758 \uacf5\ubc31 \ucd5c\uc18c\ud654 \uc815\ub3c4\ub9cc \ud558\ub294 \uac04\uacb0\ud55c \ud568\uc218\uc774\ub2e4.<\/p>\n<p>PHP\uc5d0\uc11c HTML\uc744 \ub2e4\ub8f0\ub54c \ubcf4\ud1b5 DOMDocument\ub97c \uc0ac\uc6a9\ud558\ubbc0\ub85c \ucd5c\uc18c\ud654\ud560 HTML \ucf54\ub4dc\ub97c \ubb38\uc790\uc5f4 \ub300\uc2e0\uc5d0 DOMDocument \uac1d\uccb4\ub97c \ud568\uc218\uc758 \uc778\uc790\ub85c \ubc1b\uc558\ub2e4.<\/p>\n<p>HTML \ucf54\ub4dc\ub97c \ubb38\uc790\uc5f4\ub85c \ubc1b\uace0 \ud568\uc218 \ub0b4\ubd80\uc5d0\uc11c DOMDocument \uac1d\uccb4\ub97c \uc0dd\uc131\ud574\ub3c4 \ub418\uc9c0 \uc54a\uc744\uc9c0\uac00 \uad81\uae08\ud560\ud150\ub370 DOMDocument\uac00 HTML\uc744 \uc77d\uc5b4 \ub4e4\uc77c \ub54c \ub2e4\uc74c\uacfc \uac19\uc740 \ub2e4\uc591\ud55c \uc0c1\ud669\uc774 \uc874\uc7ac\ud55c\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">$doc = new \\DOMDocument();\r\n$doc-&gt;loadHTML($html, LIBXML_NOERROR | LIBXML_HTML_NODEFDTD | LIBXML_NOBLANKS);<\/pre>\n<p>\ub54c\ubb38\uc5d0 \ud568\uc218 \ubc16\uc5d0\uc11c \ud638\ucd9c\uc790\uc758 \uc785\ub9db\ub300\ub85c \ub9cc\ub4e4\uc5b4\uc9c4 DOMDocument \uac1d\uccb4\ub97c \ubc1b\uc544\uc11c \ucc98\ub9ac\ud558\ub294 \uac83\uc774 \ub0ab\ub2e4.<\/p>\n<p>HTML \ucf54\ub4dc\ub97c \ub354 \uc904\uc774\uae30 \uc704\ud574\uc11c HTML \ucf54\ub4dc\ub97c \ucd9c\ub825 \uc2dc \uc18d\uc131 \uac12\uc5d0 \uacf5\ubc31\uc774 \uc5c6\uc73c\uba74 \ub530\uc634\ud45c\ub97c \uc81c\uac70\ud558\ub294 \ub4f1\uc758 \ucc98\ub9ac\ub97c \ucd94\uac00 \ud560 \uc218 \uc788\uc9c0\ub9cc \ucf54\ub4dc\uac00 \uc904\uc5b4\ub4dc\ub294 \uc591\uc5d0 \ube44\ud574\uc11c \uc608\uc0c1\uce58 \ubabb\ud55c \ubc84\uadf8\uac00 \ubc1c\uc0dd\ud560 \uc704\ud5d8\uc131\uc744 \uc0dd\uac01\ud558\uba74 \ub531 \uc774 \uc815\ub3c4\uac00 \ucd5c\uc801\uc774\ub77c\uace0 \uc0dd\uac01\ud55c\ub2e4.<\/p>\n<p>PHP \ud328\ud0a4\uc9c0\ub85c \ub9cc\ub4e4\uae30\uc5d0\ub294 \ucf54\ub4dc\uac00 \uc9e7\uae30\uc5d0 \ud544\uc694\ud558\ub2e4\uba74 \uac01\uc790\uc758 \ud504\ub85c\uc81d\ud2b8\uc5d0 \uc720\ud2f8 \ud074\ub798\uc2a4\uc758 \uc815\uc801 \uba54\uc18c\ub4dc\ub85c \ub9cc\ub4e4\uc5b4 \uc0ac\uc6a9\ud558\ub294 \uc815\ub3c4\ub85c \ucda9\ubd84\ud558\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTML \ucf54\ub4dc \ucd5c\uc18c\ud654(minify)\uc6a9\uc73c\ub85c wyrihaximus\/html-compress \ud328\ud0a4\uc9c0\ub97c \uc0ac\uc6a9\ud558\uace0 \uc788\uc5c8\ub294\ub370 PHP 8.3\uc5d0\uc11c TypeError\uac00 \ubc1c\uc0dd\ud588\ub2e4. \uc774\ubbf8 \uc791\ub144 12\uc6d4\uc5d0 \ubc84\uadf8 \ud328\uce58 PR\uc774 \uc62c\ub77c\uc640 \uc788\uc74c\uc5d0\ub3c4 \uc218\uac1c\uc6d4\uac04 \uc544\ubb34\ub7f0 \uc751\ub2f5\uc774 \uc5c6\ub2e4. (Uncaught TypeError with PHP 8.3 and id attribute) \uc0c8\ub85c\uc6b4 \ubc84\uc804\uc774 \ubc30\ud3ec\ub420 \uac83\uc774\ub77c\ub294 \uae30\ub300\ub97c \ubc84\ub9ac\uace0 \ub2e4\ub978 \ud328\ud0a4\uc9c0\ub4e4\uc744 \ucc3e\uc544\ubd24\uc9c0\ub9cc \ub9c8\ub545\ud55c \uac83\uc744 \ucc3e\uc9c0 \ubabb\ud588\ub2e4. \uadf8\ub798\uc11c \uc9c1\uc811 \uad6c\ud604\ud558\uae30\ub85c \ud588\ub2e4. \/** * DOM Document minify * * [&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":[153,152],"_links":{"self":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1903"}],"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=1903"}],"version-history":[{"count":4,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1903\/revisions"}],"predecessor-version":[{"id":1907,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1903\/revisions\/1907"}],"wp:attachment":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}