{"id":64,"date":"2013-12-03T02:59:47","date_gmt":"2013-12-02T18:59:47","guid":{"rendered":"http:\/\/www.yptk.cn\/index.php\/2013\/12\/03\/%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e4%ba%8c%e5%a4%a9\/"},"modified":"2013-12-03T02:59:47","modified_gmt":"2013-12-02T18:59:47","slug":"%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e4%ba%8c%e5%a4%a9","status":"publish","type":"post","link":"http:\/\/yptk.cn\/index.php\/2013\/12\/03\/%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e4%ba%8c%e5%a4%a9\/","title":{"rendered":"\u5341\u5929\u5b66\u4f1aphp\u4e4b\u7b2c\u4e8c\u5929"},"content":{"rendered":"<p><span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">\u5b66\u4e60\u76ee\u7684\uff1a\u638c\u63e1php\u7684\u6d41\u7a0b\u63a7\u5236&nbsp;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; 1\u3001if..else \u5faa\u73af\u6709\u4e09\u79cd\u7ed3\u6784<\/span><\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u7b2c\u4e00\u79cd\u662f\u53ea\u6709\u7528\u5230 if \u6761\u4ef6\uff0c\u5f53\u4f5c\u5355\u7eaf\u7684\u5224\u65ad\u3002\u89e3\u91ca\u6210 &#8220;\u82e5\u53d1\u751f\u4e86\u67d0\u4e8b\u5219\u600e\u6837\u5904\u7406&#8221;\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; if (expr) { statement }\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u5176\u4e2d\u7684 expr \u4e3a\u5224\u65ad\u7684\u6761\u4ef6\uff0c\u901a\u5e38\u90fd\u662f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u53f7\u5f53\u5224\u65ad\u7684\u6761\u4ef6\u3002\u800c statement \u4e3a\u7b26\u5408\u6761\u4ef6\u7684\u6267\u884c\u90e8\u5206\u7a0b\u5e8f\uff0c\u82e5\u7a0b\u5e8f\u53ea\u6709\u4e00\u884c\uff0c\u53ef\u4ee5\u7701\u7565\u5927\u62ec\u53f7 {}\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u8303\u4f8b\uff1a\u672c\u4f8b\u7701\u7565\u5927\u62ec\u53f7\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; &lt;?php&nbsp;<br \/>\n&nbsp; if ($state==1)echo &#8220;\u54c8\u54c8&#8221; ;&nbsp;<br \/>\n&nbsp; ?&gt;&nbsp;<br \/>\n<span class=\"style1\"><span style=\"color:#ff0000;\"><span style=\"color:#000000;\">&nbsp;&nbsp;<\/span>\u8fd9\u91cc\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5224\u65ad\u662f\u5426\u76f8\u7b49\u662f==\u800c\u4e0d\u662f=\uff0cASP\u7a0b\u5e8f\u5458\u53ef\u80fd\u5e38\u72af\u8fd9\u4e2a\u9519\u8bef\uff0c= \u662f\u8d4b\u503c\u3002<\/span><\/span>\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u8303\u4f8b\uff1a\u672c\u4f8b\u7684\u6267\u884c\u90e8\u5206\u6709\u4e09\u884c\uff0c\u4e0d\u53ef\u7701\u7565\u5927\u62ec\u53f7\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; &lt;?php&nbsp;<br \/>\n&nbsp; if ($state==1) {&nbsp;<br \/>\n&nbsp; echo &#8220;\u54c8\u54c8 ;&nbsp;<br \/>\n&nbsp; echo &#8220;&lt;br&gt;&#8221; ;&nbsp;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; ?&gt;\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u7b2c\u4e24\u79cd\u662f\u9664\u4e86 if \u4e4b\u5916\uff0c\u52a0\u4e0a\u4e86 else \u7684\u6761\u4ef6\uff0c\u53ef\u89e3\u91ca\u6210 &#8220;\u82e5\u53d1\u751f\u4e86\u67d0\u4e8b\u5219\u600e\u6837\u5904\u7406\uff0c\u5426\u5219\u8be5\u5982\u4f55\u89e3\u51b3&#8221;\u3002\u8bed\u6cd5\u5982\u4e0b\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\tif (expr) { statement1 } else { statement2 } \u8303\u4f8b\uff1a\u4e0a\u9762\u7684\u4f8b\u5b50\u6765\u4fee\u6539\u6210\u66f4\u5b8c\u6574\u7684\u5904\u7406\u3002\u5176\u4e2d\u7684 else \u7531\u4e8e\u53ea\u6709\u4e00\u884c\u6267\u884c\u7684\u6307\u4ee4\uff0c\u56e0\u6b64\u4e0d\u7528\u52a0\u4e0a\u5927\u62ec\u53f7\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; &lt;?php&nbsp;<br \/>\n&nbsp; if ($state==1) {&nbsp;<br \/>\n&nbsp; echo &#8220;\u54c8\u54c8&#8221; ;&nbsp;<br \/>\n&nbsp; echo &#8220;&lt;br&gt;&#8221;;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; else{<br \/>\n&nbsp; echo &#8220;\u5475\u5475&#8221;;<br \/>\n&nbsp; echo &#8220;&lt;br&gt;&#8221;;&nbsp;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; ?&gt;\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u7b2c\u4e09\u79cd\u5c31\u662f\u9012\u5f52\u7684 if..else \u5faa\u73af\uff0c\u901a\u5e38\u7528\u5728\u591a\u79cd\u51b3\u7b56\u5224\u65ad\u65f6\u3002\u5b83\u5c06\u6570\u4e2a if..else \u62ff\u6765\u5408\u5e76\u8fd0\u7528\u5904\u7406\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u76f4\u63a5\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; &lt;?php&nbsp;<br \/>\n&nbsp; if ( $a &gt; $b ) {&nbsp;<br \/>\n&nbsp; echo &#8220;a \u6bd4 b \u5927&#8221; ;&nbsp;<br \/>\n&nbsp; } elseif ( $a == $b ) {&nbsp;<br \/>\n&nbsp; echo &#8220;a \u7b49\u4e8e b&#8221; ;&nbsp;<br \/>\n&nbsp; } else {&nbsp;<br \/>\n&nbsp; echo &#8220;a \u6bd4 b \u5c0f&#8221; ;&nbsp;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; ?&gt;&nbsp;<br \/>\n\u4e0a\u4f8b\u53ea\u7528\u4e8c\u5c42\u7684 if..else \u5faa\u73af\uff0c\u7528\u6765\u6bd4\u8f83 a \u548c b \u4e24\u4e2a\u53d8\u91cf\u3002\u5b9e\u9645\u8981\u4f7f\u7528\u8fd9\u79cd\u9012\u5f52 if..else \u5faa\u73af\u65f6\uff0c\u8bf7\u5c0f\u5fc3\u4f7f\u7528\uff0c\u56e0\u4e3a\u592a\u591a\u5c42\u7684\u5faa\u73af\u5bb9\u6613\u4f7f\u8bbe\u8ba1\u7684\u903b\u8f91\u51fa\u95ee\u9898\uff0c\u6216\u8005\u5c11\u6253\u4e86\u5927\u62ec\u53f7\u7b49\uff0c\u90fd\u4f1a\u9020\u6210\u7a0b\u5e8f\u51fa\u73b0\u83ab\u540d\u5176\u5999\u7684\u95ee\u9898\u3002&nbsp;\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp;2\u3001 for \u5faa\u73af\u5c31\u5355\u7eaf\u53ea\u6709\u4e00\u79cd\uff0c\u6ca1\u6709\u53d8\u5316\uff0c\u5b83\u7684\u8bed\u6cd5\u5982\u4e0b\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; for (expr1; expr2; expr3) { statement }\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u5176\u4e2d\u7684 expr1 \u4e3a\u6761\u4ef6\u7684\u521d\u59cb\u503c\u3002expr2 \u4e3a\u5224\u65ad\u7684\u6761\u4ef6\uff0c\u901a\u5e38\u90fd\u662f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u53f7 (logical operators) \u5f53\u5224\u65ad\u7684\u6761\u4ef6\u3002expr3 \u4e3a\u6267\u884c statement \u540e\u8981\u6267\u884c\u7684\u90e8\u4efd\uff0c\u7528\u6765\u6539\u53d8\u6761\u4ef6\uff0c\u4f9b\u4e0b\u6b21\u7684\u5faa\u73af\u5224\u65ad\uff0c\u5982\u52a0\u4e00..\u7b49\u7b49\u3002\u800c statement \u4e3a\u7b26\u5408\u6761\u4ef6\u7684\u6267\u884c\u90e8\u5206\u7a0b\u5e8f\uff0c\u82e5\u7a0b\u5e8f\u53ea\u6709\u4e00\u884c\uff0c\u53ef\u4ee5\u7701\u7565\u5927\u62ec\u53f7 {}\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u4e0b\u4f8b\u662f\u7528 for \u5faa\u73af\u5199\u7684\u7684\u4f8b\u5b50\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; &lt;?php&nbsp;<br \/>\n&nbsp; for ( $i = 1 ; $i &lt;= 10 ; $i ++) {&nbsp;<br \/>\n&nbsp; echo &#8220;\u8fd9\u662f\u7b2c&#8221;.$i.&#8221;\u6b21\u5faa\u73af&lt;br&gt;&#8221; ;&nbsp;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; ?&gt;&nbsp;<br \/>\n&nbsp; 3\u3001 switch \u5faa\u73af\uff0c\u901a\u5e38\u5904\u7406\u590d\u5408\u5f0f\u7684\u6761\u4ef6\u5224\u65ad\uff0c\u6bcf\u4e2a\u5b50\u6761\u4ef6\uff0c\u90fd\u662f case \u6307\u4ee4\u90e8\u5206\u3002\u5728\u5b9e\u4f5c\u4e0a\u82e5\u4f7f\u7528\u8bb8\u591a\u7c7b\u4f3c\u7684 if \u6307\u4ee4\uff0c\u53ef\u4ee5\u5c06\u5b83\u7efc\u5408\u6210 switch \u5faa\u73af\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u8bed\u6cd5\u5982\u4e0b\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; switch (expr) { case expr1: statement1; break; case expr2: statement2; break; default: statementN; break; }\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u5176\u4e2d\u7684 expr \u6761\u4ef6\uff0c\u901a\u5e38\u4e3a\u53d8\u91cf\u540d\u79f0\u3002\u800c case \u540e\u7684 exprN\uff0c\u901a\u5e38\u8868\u793a\u53d8\u91cf\u503c\u3002\u5192\u53f7\u540e\u5219\u4e3a\u7b26\u5408\u8be5\u6761\u4ef6\u8981\u6267\u884c\u7684\u90e8\u5206\u3002\u6ce8\u610f\u8981\u7528 break \u8df3\u79bb\u5faa\u73af\u3002&nbsp;<br \/>\n&lt;?php&nbsp;<br \/>\n&nbsp; switch ( date ( &#8220;D&#8221; )) {&nbsp;<br \/>\n&nbsp; case &#8220;Mon&#8221; :&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u661f\u671f\u4e00&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; case &#8220;Tue&#8221; :&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u661f\u671f\u4e8c&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; case &#8220;Wed&#8221; :&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u661f\u671f\u4e09&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; case &#8220;Thu&#8221; :&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u661f\u671f\u56db&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; case &#8220;Fri&#8221; :&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u661f\u671f\u4e94&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; default:&nbsp;<br \/>\n&nbsp; echo &#8220;\u4eca\u5929\u653e\u5047&#8221; ;&nbsp;<br \/>\n&nbsp; break;&nbsp;<br \/>\n&nbsp; }&nbsp;<br \/>\n&nbsp; ?&gt;&nbsp;<br \/>\n&nbsp; \u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662fbreak;\u522b\u9057\u6f0f\u4e86\uff0cdefault\uff0c\u7701\u7565\u662f\u53ef\u4ee5\u7684\u3002&nbsp;\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u5f88\u660e\u663e\u7684\uff0c\u4e0a\u8ff0\u7684\u4f8b\u5b50\u7528 if \u5faa\u73af\u5c31\u5f88\u9ebb\u70e6\u4e86\u3002\u5f53\u7136\u5728\u8bbe\u8ba1\u65f6\uff0c\u8981\u5c06\u51fa\u73b0\u673a\u7387\u6700\u5927\u7684\u6761\u4ef6\u653e\u5728\u6700\u524d\u9762\uff0c\u6700\u5c11\u51fa\u73b0\u7684\u6761\u4ef6\u653e\u5728\u6700\u540e\u9762\uff0c\u53ef\u4ee5\u589e\u52a0\u7a0b\u5e8f\u7684\u6267\u884c\u6548\u7387\u3002\u4e0a\u4f8b\u7531\u4e8e\u6bcf\u5929\u51fa\u73b0\u7684\u673a\u7387\u76f8\u540c\uff0c\u6240\u4ee5\u4e0d\u7528\u6ce8\u610f\u6761\u4ef6\u7684\u987a\u5e8f\u3002\n<\/p>\n<p style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\n\t&nbsp; \u4eca\u5929\u5c31\u8bf4\u5230\u8fd9\u91cc\uff0c\u660e\u5929\u5f00\u59cb\u8bf4\u6570\u636e\u5e93\u7684\u4f7f\u7528\u3002\n<\/p>\n<p>\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b66\u4e60\u76ee\u7684\uff1a\u638c\u63e1php\u7684\u6d41\u7a0b\u63a7\u5236&nbsp; &nbsp; 1\u3001if..else \u5faa\u73af\u6709\u4e09\u79cd\u7ed3\u6784 &nbsp; \u7b2c\u4e00\u79cd\u662f\u53ea\u6709\u7528\u5230 if \u6761\u4ef6\uff0c\u5f53\u4f5c\u5355\u7eaf\u7684\u5224\u65ad\u3002\u89e3\u91ca\u6210 &#8220;\u82e5\u53d1\u751f\u4e86\u67d0\u4e8b\u5219\u600e\u6837\u5904\u7406&#8221;\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a &nbsp; if (expr) { statement } &nbsp; \u5176\u4e2d\u7684 expr \u4e3a\u5224\u65ad\u7684\u6761\u4ef6\uff0c\u901a\u5e38\u90fd\u662f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u53f7\u5f53\u5224\u65ad\u7684\u6761\u4ef6\u3002\u800c statement \u4e3a\u7b26 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15],"tags":[],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-15"],"_links":{"self":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":0,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}