{"id":48854,"date":"2024-12-02T08:36:00","date_gmt":"2024-12-02T00:36:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48854\/"},"modified":"2024-12-02T08:36:00","modified_gmt":"2024-12-02T00:36:00","slug":"javascript-%e5%92%8c-php-%e4%b8%ad%e5%a6%82%e4%bd%95%e8%bf%87%e6%bb%a4%e7%89%b9%e6%ae%8a%e5%ad%97%e7%ac%a6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48854\/","title":{"rendered":"JavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>JavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p><span style=\"font-size: 15px\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aJavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241101\/17304655056724cee113fa7.jpg\" class=\"aligncenter\" title=\"JavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f\u63d2\u56fe\" alt=\"JavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\u4ee5\u907f\u514d javascript \u62a5\u9519<\/strong><\/p>\n<p>\u5728 web \u5f00\u53d1\u4e2d\uff0c\u5904\u7406\u7279\u6b8a\u5b57\u7b26\u65f6\uff0cjavascript \u811a\u672c\u53ef\u80fd\u4f1a\u9047\u5230\u9519\u8bef\u3002\u8fd9\u4e9b\u5b57\u7b26\u901a\u5e38\u662f\u4e0d\u53ef\u6253\u5370\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\u65b9\u6846\u6216\ufffd\uff0c\u65e0\u6cd5\u901a\u8fc7\u6807\u51c6\u5b57\u7b26\u7f16\u7801\u65b9\u6848\uff08\u4f8b\u5982 ascii\uff09\u6765\u8868\u793a\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>javascript<\/strong><\/p>\n<pre>const text = `js\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\ufffd\ufffd\ufffd\ufffd\ufffd\u8fd9\u79cd\u5b57\u7b26\uff1f`;\n\n\/\/ \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u6240\u6709\u975e\u6253\u5370\u5b57\u7b26\nconst filteredtext = text.replace(\/[\\x00-\\x1f]+\/g, '');\n\nconsole.log(filteredtext); \/\/ \u8f93\u51fa\uff1ajs\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\u8fd9\u79cd\u5b57\u7b26\uff1f<\/pre>\n<p><strong>php<\/strong><\/p>\n<pre>$text = 'js\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\ufffd\ufffd\ufffd\ufffd\ufffd\u8fd9\u79cd\u5b57\u7b26\uff1f';\n\n\/\/ \u4f7f\u7528\u5185\u7f6e\u51fd\u6570 htmlspecialchars() \u8f6c\u6362\u7279\u6b8a\u5b57\u7b26\n$filteredtext = htmlspecialchars($text);\n\necho $filteredtext; \/\/ \u8f93\u51fa\uff1ajs\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;\u8fd9\u79cd\u5b57\u7b26\uff1f<\/pre>\n<p><strong>\u4fdd\u5b58\u5230\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5c06\u7279\u6b8a\u5b57\u7b26\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 x \u9003\u9038\u5e8f\u5217\uff0c\u5b83\u5141\u8bb8\u60a8\u4fdd\u5b58\u5341\u516d\u8fdb\u5236\u8868\u793a\u7684\u5b57\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>\/\/ \\xF0 \u5f00\u5934\u7684\u5b57\u9762\u91cf\u8868\u793a\u4e00\u4e2a UTF-8 \u5b57\u7b26\n$specialCharacter = \"\\xF0\\xA0\\x80\\x80\";<\/pre>\n<p>\u5728\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 utf8_encode() \u51fd\u6570\u5c06 utf-8 \u7f16\u7801\u7684\u5b57\u7b26\u8f6c\u6362\u4e3a ascii\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aJavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1aphp \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f \u6536\u85cf \u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\u300aJavaScript \u548c PHP \u4e2d\u5982\u4f55\u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\uff1f\u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60\u6587\u7ae0\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01 \u8fc7\u6ee4\u7279\u6b8a\u5b57\u7b26\u4ee5\u907f\u514d javascript \u62a5\u9519 \u5728 web \u5f00\u53d1\u4e2d\uff0c\u5904\u7406\u7279\u6b8a\u5b57\u7b26\u65f6\uff0cjavascript \u811a\u672c\u53ef\u80fd\u4f1a\u9047\u5230\u9519\u8bef\u3002\u8fd9\u4e9b\u5b57\u7b26\u901a\u5e38\u662f\u4e0d\u53ef\u6253\u5370\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\u65b9\u6846\u6216\ufffd\uff0c\u65e0\u6cd5\u901a\u8fc7\u6807\u51c6\u5b57\u7b26\u7f16\u7801\u65b9\u6848\uff08\u4f8b\u5982 ascii\uff09\u6765\u8868\u793a\u3002 \u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a javascript const text = `js\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\ufffd\ufffd\ufffd\ufffd\ufffd\u8fd9\u79cd\u5b57\u7b26\uff1f`; \/\/ \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u6240\u6709\u975e\u6253\u5370\u5b57\u7b26 const filteredtext = text.replace(\/[\\x00-\\x1f]+\/g, &#8221;); console.log(filteredtext); \/\/ \u8f93\u51fa\uff1ajs\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\u8fd9\u79cd\u5b57\u7b26\uff1f php $text = &#8216;js\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389\ufffd\ufffd\ufffd\ufffd\ufffd\u8fd9\u79cd\u5b57\u7b26\uff1f&#8217;; \/\/ \u4f7f\u7528\u5185\u7f6e\u51fd\u6570 htmlspecialchars() \u8f6c\u6362\u7279\u6b8a\u5b57\u7b26 $filteredtext = htmlspecialchars($text); echo $filteredtext; \/\/ \u8f93\u51fa\uff1ajs\u6216\u8005php\u5982\u4f55\u8fc7\u6ee4\u6389&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;&amp;amp;#32;\u8fd9\u79cd\u5b57\u7b26\uff1f \u4fdd\u5b58\u5230\u6570\u636e\u5e93 \u5982\u679c\u9700\u8981\u5c06\u7279\u6b8a\u5b57\u7b26\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 x \u9003\u9038\u5e8f\u5217\uff0c\u5b83\u5141\u8bb8\u60a8\u4fdd\u5b58\u5341\u516d\u8fdb\u5236\u8868\u793a\u7684\u5b57\u7b26\u3002\u4f8b\u5982\uff1a \/\/ \\xF0 \u5f00\u5934\u7684\u5b57\u9762\u91cf\u8868\u793a\u4e00\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48854","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48854"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48854\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}