{"id":661,"date":"2010-10-11T13:03:56","date_gmt":"2010-10-11T05:03:56","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=661"},"modified":"2010-10-12T13:07:34","modified_gmt":"2010-10-12T05:07:34","slug":"phppreg_match_all%e8%88%87%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%a4%ba%e6%b3%95","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=661","title":{"rendered":"[PHP]preg_match_all\u8207\u6b63\u898f\u8868\u793a\u6cd5"},"content":{"rendered":"<p>\u81ea\u5f9e\u7562\u696d\u4ee5\u5f8c\uff0c\u6bd4\u8f03\u6709\u9592\u958b\u59cb\u5728\u6ce8\u610f\u9ec3\u91d1\u8207\u5916\u5e63\uff0c\u9019\u6bb5\u671f\u9593\u9ec3\u91d1\u4e00\u76f4\u5c45\u9ad8\u4e0d\u4e0b\uff0c\u4e00\u76f4\u7b49\u4e0d\u5230\u9069\u5408\u7684\u9032\u5834\u6642\u9593\u3002\u525b\u597d\u9047\u9022\u8fd1\u65e5\u53f0\u5e63\u8d70\u63da\uff0c\u7f8e\u5143\u76f8\u5c0d\u8d70\u5f31\u3002\u96d6\u7136\u524d\u9663\u5b50\u6211\u662f\u5df2\u7d93\u9032\u5834\u4e86\uff0c\u4f46\u7f8e\u5143\u9084\u662f\u6301\u7e8c\u75b2\u8edf\uff0c\u6240\u4ee5\u6211\u4e5f\u53ea\u80fd\u653e\u8457\u3002\u6b64\u6642\u6211\u9084\u95dc\u6ce8\u5176\u4ed6\u570b\u5bb6\u7684\u8ca8\u5e63\uff0c\u56e0\u6b64\u5c31\u6c7a\u5b9a\u5beb\u4e00\u500b\u7db2\u9801\uff0c\u5c07\u53f0\u7063\u9280\u884c\u4e0a\u9762\u7684\u6240\u6709\u8ca8\u5e63\u622a\u53d6\u51fa\u4f86\u4ee5\u65b9\u4fbf\u76f4\u63a5\u89c0\u770b\u3002<\/p>\n<p><!--more-->\u6b64\u6642\u60f3\u5230\u6700\u597d\u7684\u5de5\u5177\u61c9\u8a72\u5c31\u662fphp\u4e86\uff0c\u5df2\u7d93\u6709\u5169\u5e74\u6c92\u78b0php\uff0c\u7a81\u7136\u9593\u89ba\u5f97\u6709\u9ede\u751f\u758f\uff0c\u4e0a\u7db2\u627e\u5230\u6bd4\u8f03\u9069\u5408\u7528\u4f86\u64f7\u53d6\u7db2\u9801\u8cc7\u8a0a\u7684\u51fd\u5f0f\u5c31\u5c6c<a href=\"http:\/\/php.net\/manual\/en\/function.preg-match-all.php\" target=\"_blank\">preg_match_all<\/a>\uff0c\u8a72\u51fd\u6578\u9700\u8981\u4e94\u500b\u53c3\u6578\uff0c\u5176\u4e2d\u4e00\u500b\u662f\u9078\u7528\u7684\uff0c\u56e0\u6b64\u5927\u591a\u4f7f\u7528\u56db\u500b\u53c3\u6578\uff0c\u7b2c\u4e00\u500b\u53c3\u6578pattern\uff0c\u662f\u7528\u6b63\u898f\u8868\u793a\u6cd5\u898f\u5247\u4f86\u6574\u9ad4\u5256\u6790\u6bd4\u5c0d\u5b57\u4e32 subject\u3002\u7b2c\u4e8c\u500b\u53c3\u6578subject\u5373\u70ba\u8981\u6bd4\u5c0d\u7684\u5b57\u4e32\u5167\u5bb9\uff0c\u7b2c\u4e09\u500b\u53c3\u6578matches\u662f\u5c07\u6bd4\u5c0d\u7d50\u679c\u50b3\u56de\u7684\u503c\u653e\u5728\u9663\u5217\u3002<br \/>\n\u5176\u5be6\u6211\u73fe\u5728\u9084\u662f\u6709\u9ede\u4e00\u4f3c\u61c2\u975e\u61c2\uff0c\u4f46\u6211\u9084\u662f\u6574\u7406\u4e86\u4ee5\u4e0b\u4e0d\u932f\u7684\u8cc7\u6599\u8b93\u5927\u5bb6\u6bd4\u8f03\u4e00\u4e0b\uff1a<\/p>\n<p>1.\u9996\u5148\u5148\u8981\u4e86\u89e3\u4ec0\u9ebc\u662f\u6b63\u898f\u8868\u793a\u6cd5\uff0c\u7db2\u8def\u4e0a\u96f6\u96f6\u7e3d\u7e3d\u7684\u8b1b\u89e3\uff0c\u4f3c\u4e4e\u53ea\u6703\u8b93\u4eba\u66f4\u4e00\u982d\u9727\u6c34\u3002\u56e0\u6b64\u7b2c\u4e00\u6b21\u63a5\u89f8\u7684\u4eba\u6211\u89ba\u5f97\u9ce5\u54e5\u6240\u5beb\u7684<a href=\"http:\/\/linux.vbird.org\/linux_basic\/0330regularex.php\" target=\"_blank\">\u6b63\u898f\u8868\u793a\u6cd5<\/a>\u6703\u8b93\u4eba\u6bd4\u5c31\u5bb9\u6613\u61c2\uff0c\u5982\u679c\u5927\u81f4\u90fd\u4e86\u89e3\u5f8c\uff0c\u518d\u4f86\u505a\u500b\u7a2e\u6574\u7406<a href=\"http:\/\/neural.cs.nthu.edu.tw\/jang\/books\/webprog\/03jscript\/reg3.asp?SessionCount=15\" target=\"_blank\">\u6b63\u898f\u8868\u793a\u767c\u5217\u8868<\/a>\uff1a<\/p>\n<table border=\"1\" cellspacing=\"0\" align=\"center\" bgcolor=\"white\">\n<tbody>\n<tr>\n<th class=\"boldw\">\u5b57\u5143<\/th>\n<th class=\"boldw\">\u8aaa\u660e<\/th>\n<th class=\"boldw\">\u7c21\u55ae\u7bc4\u4f8b<\/th>\n<\/tr>\n<tr>\n<td align=\"middle\">\\<\/td>\n<td>\u907f\u958b\u7279\u6b8a\u5b57\u5143<\/td>\n<td>\/A\\*\/ \u53ef\u7528\u65bc\u6bd4\u5c0d \"A*\"\uff0c\u5176\u4e2d * \u662f\u4e00\u500b\u7279\u6b8a\u5b57\u5143\uff0c\u70ba\u907f\u958b\u5176\u7279\u6b8a\u610f\u7fa9\uff0c\u6240\u4ee5\u5fc5\u9808\u52a0\u4e0a \"\\\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">^<\/td>\n<td>\u6bd4\u5c0d\u8f38\u5165\u5217\u7684\u555f\u59cb\u4f4d\u7f6e<\/td>\n<td>\/^A\/ \u53ef\u6bd4\u5c0d \"Abcd\" \u4e2d\u7684 \"A\"\uff0c\u4f46\u4e0d\u53ef\u6bd4\u5c0d \"aAb\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">$<\/td>\n<td>\u6bd4\u5c0d\u8f38\u5165\u5217\u7684\u7d50\u675f\u4f4d\u7f6e<\/td>\n<td>\/A$\/ \u53ef\u6bd4\u5c0d \"bcdA\" \u4e2d\u7684 \"A\"\uff0c\u4f46\u4e0d\u53ef\u6bd4\u5c0d \"aAb\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">*<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143\u96f6\u6b21\u6216\u66f4\u591a\u6b21<\/td>\n<td>\/bo*\/ \u53ef\u6bd4\u5c0d \"Good booook\" \u4e2d\u7684 \"booo\"\uff0c\u4ea6\u53ef\u6bd4\u5c0d \"Good bk\" \u4e2d\u7684 \"b\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">+<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143\u4e00\u6b21\u6216\u66f4\u591a\u6b21\uff0c\u7b49\u6548\u65bc {1,}<\/td>\n<td>\/a+\/ \u53ef\u6bd4\u5c0d \"candy\" \u4e2d\u7684 \"a\"\uff0c\u4f46\u4e0d\u53ef\u6bd4\u5c0d \"caaandy\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">?<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143\u96f6\u6b21\u6216\u4e00\u6b21<\/td>\n<td>\/e?le?\/ \u53ef\u6bd4\u5c0d \"angel\" \u4e2d\u7684 \"el\"\uff0c\u4f46\u4e0d\u53ef\u6bd4\u5c0d \"angle\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">.<\/td>\n<td>\u6bd4\u5c0d\u4efb\u4f55\u4e00\u500b\u5b57\u5143\uff08\u4f46\u63db\u884c\u7b26\u865f\u4e0d\u7b97\uff09<\/td>\n<td>\/.n\/ \u53ef\u6bd4\u5c0d \"nay, an apple is on the tree\" \u4e2d\u7684 \"an\" \u548c \"on\"\uff0c\u4f46\u4e0d\u53ef\u6bd4\u5c0d \"nay\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">(x)<\/td>\n<td>\u6bd4\u5c0d x \u4e26\u5c07\u7b26\u5408\u7684\u90e8\u5206\u5b58\u5165\u4e00\u500b\u8b8a\u6578<\/td>\n<td>\/(a*) and (b*)\/ \u53ef\u6bd4\u5c0d \"aaa and bb\" \u4e2d\u7684 \"aaa\" \u548c \"bb\"\uff0c\u4e26\u5c07\u9019\u5169\u500b\u6bd4\u5c0d\u5f97\u5230\u7684\u5b57\u4e32\u8a2d\u5b9a\u81f3\u8b8a\u6578 RegExp.$1 \u548c RegExp.$2\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">xy<\/td>\n<td>\u6bd4\u5c0d x \u6216 y<\/td>\n<td>\/a*b*\/g \u53ef\u6bd4\u5c0d \"aaa and bb\" \u4e2d\u7684 \"aaa\" \u548c \"bb\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">{n}<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143 n \u6b21\uff0cn \u70ba\u4e00\u500b\u6b63\u6574\u6578<\/td>\n<td>\/a{3}\/ \u53ef\u6bd4\u5c0d \"lllaaalaa\" \u5176\u4e2d\u7684 \"aaa\" \u4f46\u4e0d\u53ef\u6bd4\u5c0d \"aa\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">{n,}<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143\u81f3\u5c11 n \u6b21\uff0cn \u70ba\u4e00\u500b\u6b63\u6574\u6578<\/td>\n<td>\/a{3,}\/ \u53ef\u6bd4\u5c0d \"aa aaa aaaa\" \u5176\u4e2d\u7684 \"aaa\" \u53ca \"aaaa\" \u4f46\u4e0d\u53ef\u6bd4\u5c0d \"aa\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">{n,m}<\/td>\n<td>\u6bd4\u5c0d\u524d\u4e00\u500b\u5b57\u5143\u81f3\u5c11 n \u6b21\uff0c\u81f3\u591a m \u6b21\uff0cm\u3001n \u5747\u70ba\u6b63\u6574\u6578<\/td>\n<td>\/a{3,4}\/ \u53ef\u6bd4\u5c0d \"aa aaa aaaa aaaaa\" \u5176\u4e2d\u7684 \"aaa\" \u53ca \"aaaa\" \u4f46\u4e0d\u53ef\u6bd4\u5c0d \"aa\" \u53ca \"aaaaa\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">[xyz]<\/td>\n<td>\u6bd4\u5c0d\u4e2d\u62ec\u5f27\u5167\u7684\u4efb\u4e00\u500b\u5b57\u5143<\/td>\n<td>\/[ecm]\/ \u53ef\u6bd4\u5c0d \"welcome\" \u4e2d\u7684 \"e\" \u6216 \"c\" \u6216 \"m\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">[^xyz]<\/td>\n<td>\u6bd4\u5c0d\u4e0d\u5728\u4e2d\u62ec\u5f27\u5167\u51fa\u73fe\u7684\u4efb\u4e00\u500b\u5b57\u5143<\/td>\n<td>\/[^ecm]\/ \u53ef\u6bd4\u5c0d \"welcome\" \u4e2d\u7684 \"w\" \"l\" \"o\" \u53ef\u898b\u51fa\u5176\u8207 [xyz] \u529f\u80fd\u76f8\u53cd \u540c\u6642\u8acb\u540c\u5b78\u4e5f\u6ce8\u610f \/^\/ \u8207 [^] \u4e4b\u9593\u529f\u80fd\u7684\u4e0d\u540c<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">[\\b]<\/td>\n<td>\u6bd4\u5c0d\u9000\u4f4d\u5b57\u5143\uff08Backspace character\uff09<\/td>\n<td>\u53ef\u4ee5\u6bd4\u5c0d\u4e00\u500b backspace \uff0c\u4e5f\u8acb\u6ce8\u610f [\\b] \u8207 \\b \u4e4b\u9593\u7684\u5dee\u5225<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\b<\/td>\n<td>\u6bd4\u5c0d\u82f1\u6587\u5b57\u7684\u908a\u754c\uff0c\u4f8b\u5982\u7a7a\u683c<\/td>\n<td>\u4f8b\u5982 \/\\bn\\w\/ \u53ef\u4ee5\u6bd4\u5c0d \"noonday\" \u4e2d\u7684 'no' ;<br \/>\n\/\\wy\\b\/ \u53ef\u6bd4\u5c0d \"possibly yesterday.\" \u4e2d\u7684 'ly'<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\B<\/td>\n<td>\u6bd4\u5c0d\u975e\u300c\u82f1\u6587\u5b57\u7684\u908a\u754c\u300d<\/td>\n<td>\u4f8b\u5982, \/\\w\\Bn\/ \u53ef\u4ee5\u6bd4\u5c0d \"noonday\" \u4e2d\u7684 'on' ,<br \/>\n\u53e6\u5916 \/y\\B\\w\/ \u53ef\u4ee5\u6bd4\u5c0d \"possibly yesterday.\" \u4e2d\u7684 'ye'<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\cX<\/td>\n<td>\u6bd4\u5c0d\u63a7\u5236\u5b57\u5143\uff08Control character\uff09\uff0c\u5176\u4e2d X \u662f\u4e00\u500b\u63a7\u5236\u5b57\u5143<\/td>\n<td>\/\\cM\/ \u53ef\u4ee5\u6bd4\u5c0d \u4e00\u500b\u5b57\u4e32\u4e2d\u7684 control-M<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\d<\/td>\n<td>\u6bd4\u5c0d\u4efb\u4e00\u500b\u6578\u5b57\uff0c\u7b49\u6548\u65bc [0-9]<\/td>\n<td>\/[\\d]\/ \u53ef\u6bd4\u5c0d \u7531 \"0\" \u81f3 \"9\" \u7684\u4efb\u4e00\u6578\u5b57 \u4f46\u5176\u9918\u5982\u5b57\u6bcd\u7b49\u5c31\u4e0d\u53ef\u6bd4\u5c0d<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\D<\/td>\n<td>\u6bd4\u5c0d\u4efb\u4e00\u500b\u975e\u6578\u5b57\uff0c\u7b49\u6548\u65bc [^0-9]<\/td>\n<td>\/[\\D]\/ \u53ef\u6bd4\u5c0d \"w\" \"a\"... \u4f46\u4e0d\u53ef\u6bd4\u5c0d\u5982 \"7\" \"1\" \u7b49\u6578\u5b57<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\f<\/td>\n<td>\u6bd4\u5c0d form-feed<\/td>\n<td>\u82e5\u662f\u5728\u6587\u5b57\u4e2d\u6709\u767c\u751f \"\u63db\u9801\" \u7684\u884c\u70ba \u5247\u53ef\u4ee5\u6bd4\u5c0d\u6210\u529f<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\n<\/td>\n<td>\u6bd4\u5c0d\u63db\u884c\u7b26\u865f<\/td>\n<td>\u82e5\u662f\u5728\u6587\u5b57\u4e2d\u6709\u767c\u751f \"\u63db\u884c\" \u7684\u884c\u70ba \u5247\u53ef\u4ee5\u6bd4\u5c0d\u6210\u529f<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\r<\/td>\n<td>\u6bd4\u5c0d carriage return<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\s<\/td>\n<td>\u6bd4\u5c0d\u4efb\u4e00\u500b\u7a7a\u767d\u5b57\u5143\uff08White space character\uff09\uff0c\u7b49\u6548\u65bc [ \\f\\n\\r\\t\\v]<\/td>\n<td>\/\\s\\w*\/ \u53ef\u6bd4\u5c0d \"A b\" \u4e2d\u7684 \"b\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\S<\/td>\n<td>\u6bd4\u5c0d\u4efb\u4e00\u500b\u975e\u7a7a\u767d\u5b57\u5143\uff0c\u7b49\u6548\u65bc [^ \\f\\n\\r\\t\\v]<\/td>\n<td>\/\\S\/\\w* \u53ef\u6bd4\u5c0d \"A b\" \u4e2d\u7684 \"A\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\t<\/td>\n<td>\u6bd4\u5c0d\u5b9a\u4f4d\u5b57\u5143\uff08Tab\uff09<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\v<\/td>\n<td>\u6bd4\u5c0d\u5782\u76f4\u5b9a\u4f4d\u5b57\u5143\uff08Vertical tab\uff09<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\w<\/td>\n<td>\u6bd4\u5c0d\u6578\u5b57\u5b57\u6bcd\u5b57\u5143\uff08Alphanumerical characters\uff09\u6216\u5e95\u7dda\u5b57\u6bcd\uff08\"_\"\uff09\uff0c\u7b49\u6548\u65bc [A-Za-z0-9_]<\/td>\n<td>\/\\w\/ \u53ef\u6bd4\u5c0d \".A _!9\" \u4e2d\u7684 \"A\" \"_\" \"9\"<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\W<\/td>\n<td>\u6bd4\u5c0d\u975e\u300c\u6578\u5b57\u5b57\u6bcd\u5b57\u5143\u6216\u5e95\u7dda\u5b57\u6bcd\u300d\uff0c\u7b49\u6548\u65bc [^A-Za-z0-9_]<\/td>\n<td>\/\\W\/ \u53ef\u6bd4\u5c0d \".A _!9\" \u4e2d\u7684 \".\" \" \" \"!\" \u53ef\u898b\u51fa\u5176\u8207 \\w \u529f\u80fd\u6070\u597d\u76f8\u53cd<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\o<em>octal<\/em><\/td>\n<td>\u6bd4\u5c0d\u516b\u9032\u4f4d\uff0c\u5176\u4e2d<em>octal<em>\u662f\u516b\u9032\u4f4d\u6578\u76ee <\/em><\/em><\/td>\n<td>\/\\oocetal123\/ \u53ef\u6bd4\u5c0d \u8207 \u516b\u9032\u4f4d\u7684ASCII\u4e2d \"123\" \u6240\u76f8\u5c0d\u61c9\u7684\u5b57\u5143\u503c<\/td>\n<\/tr>\n<tr>\n<td align=\"middle\">\\x<em>hex<\/em><\/td>\n<td>\u6bd4\u5c0d\u5341\u516d\u9032\u4f4d\uff0c\u5176\u4e2d<em>hex<em>\u662f\u5341\u516d\u9032\u4f4d\u6578\u76ee <\/em><\/em><\/td>\n<td>\/\\xhex38\/ \u53ef\u6bd4\u5c0d \u8207 16\u9032\u4f4d\u7684ASCII\u4e2d \"38\" \u6240\u76f8\u5c0d\u61c9\u7684\u5b57\u5143<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>2.\u518d\u4f86\u7d66\u5e7e\u500b\u7bc4\u4f8b\u8b93\u5404\u4f4d\u53c3\u8003\uff0c\u61c9\u8a72\u6bd4\u8f03\u80fd\u7406\u89e3\u4ed6\u7684\u7528\u6cd5\uff1a<\/p>\n<p><code>\/********************** \u6b63\u898f\u8868\u793a\u6cd5\u7bc4\u4f8b *************************\/<br \/>\npreg_match_all(\"|&lt;[^&gt;]+&gt;(.*)&lt;\/[^&gt;]+&gt;|U\",<br \/>\n\"&lt;b&gt;example: &lt;\/b&gt;&lt;div align=left&gt;this is a test&lt;\/div&gt;\",<br \/>\n$out, PREG_PATTERN_ORDER);<\/code><\/p>\n<p>preg_match_all('\/\\*(.*)\\*\/sU', \"\/* \u6211\u662f\u7b2c\u4e00\u500b\u8a3b\u89e3 *\/ \u6211\u4e0d\u662f\u8a3b\u89e3 \/* \u6211\u662f\u7b2c\u4e8c\u500b\u8a3b\u89e3 *\/\", $out);<br \/>\npreg_match_all (\"\/([&lt;]div[&gt;])(.*)([&lt;][\\\/]div[&gt;])\/\",  \"&lt;div&gt;123&lt;\/div&gt;&lt;div&gt;456&lt;\/div&gt;\", $out);<\/p>\n<p>\u8acb\u81ea\u884c\u900f\u904eecho $out[0][1]\u3001$out[0][2]\u53bb\u6bd4\u8f03\u7d50\u679c<\/p>\n<p>3.\u6700\u5f8c\u6211\u518d\u7d66\u9ede\u5efa\u8b70\uff0c\u901a\u5e38\u7b2c\u4e8c\u500b\u53c3\u6578subject\u8981\u6bd4\u5c0d\u7684\u5b57\u4e32\u5167\u5bb9\uff0c\u53ef\u4ee5\u900f\u904e\u4e0b\u5217\u65b9\u5f0f\u53d6\u5f97\u518d\u4f86\u6bd4\u5c0d<\/p>\n<p><code>$handle = fopen(\"http:\/\/learn-house.idv.tw\", \"rb\");<br \/>\nwhile (!feof($handle)) {<br \/>\n$contents .= fread($handle, 8192);<br \/>\n}<br \/>\nfclose($handle);<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5f9e\u7562\u696d\u4ee5\u5f8c\uff0c\u6bd4\u8f03\u6709\u9592\u958b\u59cb\u5728\u6ce8\u610f\u9ec3\u91d1\u8207\u5916\u5e63\uff0c\u9019\u6bb5\u671f\u9593\u9ec3\u91d1\u4e00\u76f4\u5c45\u9ad8\u4e0d\u4e0b\uff0c\u4e00\u76f4\u7b49\u4e0d\u5230\u9069\u5408\u7684\u9032\u5834\u6642\u9593\u3002\u525b\u597d\u9047\u9022\u8fd1\u65e5\u53f0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-661","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/661"}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=661"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/661\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}