{"id":935,"date":"2010-03-05T15:18:00","date_gmt":"2010-03-05T07:18:00","guid":{"rendered":""},"modified":"2013-11-26T11:52:32","modified_gmt":"2013-11-26T03:52:32","slug":"php%e4%b8%ad%e5%b8%b8%e7%94%a8%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/935.html","title":{"rendered":"PHP\u4e2d\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u51fd\u6570"},"content":{"rendered":"<p>PHP\u4e2d\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u529f\u80fd\u662f\u6bd4\u8f83\u591a\u7684,\u91cd\u8981\u7684\u6709\u4ee5\u4e0b\u8fd9\u4e9b:<\/p>\n<p>(1)echo,print,printf,sprintf<br \/>\n\u524d\u4e24\u4e2a\u51fd\u6570\u662f\u8f93\u51fa\u5b57\u7b26\u4e32.\u5b57\u7b26\u4e32\u4e2d\u5982\u679c\u6709\u53d8\u91cf\u540d\u5219\u88ab\u66ff\u6362\u6210\u5176\u503c. \u540e\u4e24\u4e2a\u51fd\u6570\u7c7b\u4f3c\u4e8eC\u7684\u540c\u540d\u51fd\u6570.<\/p>\n<p>(2)strchr,strlen,strtok,strrchr,strrev,strstr,strtolower, strtoupper,substr,ucfirst<br \/>\n\u8fd9\u4e9b\u662f\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u51fd\u6570,\u6709\u4e9b\u548cC\u4e2d\u7684\u540c\u540d\u51fd\u6570\u610f\u4e49\u5b8c\u5168\u4e00\u81f4.<br \/>\nstrrev\u662f\u628a\u4e00\u4e2a\u5b57\u7b26\u4e32\u7ffb\u8f6c.<br \/>\nstrtolower\u548cstrtoupper\u7684\u610f\u601d\u5e94\u8be5\u4e0d\u7528\u89e3\u91ca\u4e86.<br \/>\nucfirst\u662f\u628a\u5b57\u7b26\u4e32\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u53d8\u6210\u5927\u5199.<br \/>\nsubstr\u662f\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u5b50\u4e32,\u7528\u6cd5\u662f:substr(\u5b57\u7b26\u4e32,\u5934,\u957f\u5ea6).<br \/>\n\u5934\u4f4d\u7f6e\u662f \u4ece0\u7b97\u8d77\u7684.\u5982\u679c\u662f\u8d1f\u6570,\u5219\u662f\u4ece\u5c3e\u90e8\u5411\u524d\u6570\u7684\u610f\u601d.<\/p>\n<p>(3)Chr,Ord<br \/>\n\u7c7b\u4f3c\u4e8eC\u7684\u540c\u540d\u51fd\u6570.<\/p>\n<p>(4)explode,implode,join<br \/>\n\u8fd9\u4e9b\u662f\u548c\u6570\u7ec4\u6709\u5173\u7684\u51fd\u6570.<br \/>\nexplode(\u5b57\u7b26\u4e32,\u5206\u5272\u7b26)\u8fd4\u56de\u4e00\u4e2a\u5c06\u5b57\u7b26\u4e32\u5728\u5206\u5272\u7b26\u5904\u5206\u5f00\u6240\u4ea7\u751f\u7684\u6570\u7ec4.<br \/>\nimplode(\u6570\u7ec4,\u5206\u5272\u7b26)\u8fd4\u56de\u4e00\u4e2a\u5c06\u6570\u7ec4\u5404\u5143\u7d20\u4e4b\u95f4\u63d2\u4e0a\u5206\u5272\u7b26\u800c\u6210\u7684\u5b57\u7b26\u4e32.<br \/>\njoin\u4e0eimplode\u610f\u4e49\u76f8\u540c.<\/p>\n<p>(5)Chop<br \/>\n\u53bb\u6389\u5b57\u7b26\u4e32\u5c3e\u90e8\u7684\u7a7a\u767d.<\/p>\n<p>(6)htmlspecialchars<br \/>\n\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684HTML\u7279\u6b8a\u5b57\u7b26\u6362\u6210\u5b83\u4eec\u7684\u540d\u5b57,\u4f8b\u5982&#8221;&lt; &#8220;\u53d8\u6210&#8221;&lt;&#8220;.<\/p>\n<p>(7)nl2br<br \/>\n\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e00\u4e2a\u56de\u8f66\u524d\u9762\u52a0\u4e0a&#8221;&lt; BR&gt;&#8221;.<\/p>\n<p>(8)AddSlashes,StripSlashes<br \/>\n\u5206\u522b\u7ed9\u5b57\u7b26\u4e32\u4e2d\u9700\u8981\u52a0\u4e0a&#8221;&#8221;\u624d\u80fd\u7528\u4e8e\u6570\u636e\u5e93\u67e5\u8be2\u7684\u5b57\u7b26\u52a0\u4e0a\u548c\u53bb\u6389&#8221;&#8221;.<\/p>\n<p>(9)parse_str<br \/>\n\u5c06&#8221;name1=value1&amp;name2=value2&amp;&#8230;&#8221;\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u5206\u6790\u6210\u4e00\u4e9b\u53d8\u91cf.<br \/>\n\u4f8b\u5982:<br \/>\nparse_str(&#8220;a=1&amp;b=2&#8243;);<br \/>\n\u751f\u6210$a\u4e0e$b\u4e24\u4e2a\u53d8\u91cf,\u503c\u5206\u522b\u4e3a1,2. \u5982\u679c\u6709\u4e24\u5bf9\u540d\u5b57\/\u503c\u7684\u540d\u5b57\u90e8\u5206\u76f8\u540c,\u5219\u540e\u4e00\u4e2a\u7684\u503c\u8986\u76d6\u524d\u4e00\u4e2a\u7684. \u5982\u679c\u8fd9\u4e24\u5bf9\u7684\u540d\u5b57\u5c3e\u90e8\u90fd\u6709&#8221;&#8221;,\u4f8b\u5982&#8221;a=1&amp;a=2&#8243;,\u5219\u751f\u6210\u6570\u7ec4$a,\u4e24\u4e2a\u5143\u7d20\u5206\u522b\u4e3a1,2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u4e2d\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u529f\u80fd\u662f\u6bd4\u8f83\u591a\u7684,\u91cd\u8981\u7684\u6709\u4ee5\u4e0b\u8fd9\u4e9b: (1)echo,print,printf,sprint [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-935","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=935"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions"}],"predecessor-version":[{"id":5239,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions\/5239"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}