 {"id":459,"date":"2012-05-21T20:43:44","date_gmt":"2012-05-21T12:43:44","guid":{"rendered":"http:\/\/www.qyuef.com\/?p=459"},"modified":"2012-05-21T20:43:44","modified_gmt":"2012-05-21T12:43:44","slug":"php%e4%b8%adwhile%e8%af%ad%e5%8f%a5%e7%9a%84%e4%b8%80%e7%82%b9%e7%90%86%e8%a7%a3%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.qyuef.com\/?p=459","title":{"rendered":"PHP\u4e2dwhile\u8bed\u53e5\u7684\u4e00\u70b9\u7406\u89e3\u7528\u6cd5"},"content":{"rendered":"<p>\u3000while\u662fphp\u91cc\u9762\u7528\u7684\u6700\u591a\u7684\u4e00\u4e2a\u51fd\u6570\uff0c\u4f46\u662f\u89c2\u5bdf\u4e86\u5f88\u4e45\uff0c\u4f46\u662f\u5f88\u591a\u4eba\u7528\u4e60\u60ef\u4e86\uff0c\u5e76\u4e0d\u77e5\u9053\u91cc\u9762\u662f\u600e\u4e48\u56de\u4e8b\uff0c\u53ea\u662f\u4e60\u60ef\u6027\u6253\u4e0a\u53bb;<\/p>\n<p>\u3000\u3000\u5148\u6d4b\u4e00\u4e0b\u4e00\u79d2\u4e2d\uff0cwhile\u53ef\u4ee5\u8fd0\u884c\u591a\u5c11\u6b21\u5faa\u73af;<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$time1 = microtime(true);<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$i =0;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while(1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$i++;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000if(microtime(true)- $time1 &gt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000echo $i;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000exit();<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000?&gt;<\/span><\/p>\n<p>\u3000\u3000\u8fd0\u884c\u7ed3\u679c<\/p>\n<p>\u3000\u3000389443;<\/p>\n<p>\u3000\u3000while\u662f\u5f53whle\u62ec\u53f7\u91cc\u9762\u7684\u6761\u4ef6\u6210\u7acb\u7684\u8bdd\uff0c\u5c31\u6267\u884c\uff0c\u8fd9\u662f\u7edd\u5bf9\u6b63\u786e\u7684<\/p>\n<p>\u3000\u3000\u6240\u4ee5while(1)\u5c31\u662f\u65e0\u9650\u5faa\u73af;<\/p>\n<p>\u3000\u3000\u5b9e\u4f8b1:<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$sql = &quot;select * from table&quot;;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$result = mysql_query($sql);<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($arr = mysql_fetch_assoc($result))<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u8fd9\u4e00\u4e2a\u7406\u89e3\u662f\u5f53while\u62ec\u53f7\u91cc\u9762$arr = mysql_fetch_assoc($result);\u6210\u7acb\u7684\u60c5\u51b5\u4e0b\uff0c\u5c31\u4f1a\u4e00\u76f4\u5f80\u4e0b\u8fd0\u884c;<\/p>\n<p>\u3000\u3000$arr = mysql_fetch_assoc($result);<\/p>\n<p>\u3000\u3000\u5f53\u6267\u884c\u8fd9\u4e2a\u67e5\u8be2\u7684\u8bdd\uff0c\u7b2c\u4e00\u6b21\uff0c\u6307\u9488\u5c31\u5bf9\u51c6\u7b2c\u4e00\u884c\uff0c\u5982\u679c\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7684\u65f6\u5019\uff0c\u4ed6\u5c31\u4f1a\u5bf9\u51c6\u7b2c\u4e8c\u884c\uff0c\u4e00\u76f4\u627e\u5230\u6ca1\u6709\u7ed3\u679c\uff0c\u8fd4\u56defalse\u5c31\u4e0d\u4f1a\u6267\u884c\u4e86<\/p>\n<p>\u3000\u3000\u9519\u8bef\u5199\u6cd5:<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$sql = &quot;select * from table&quot;;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$result = mysql_query($sql);<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$arr = mysql_fetch_assoc($result));<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($arr = mysql_fetch_assoc($result))<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u8fd9\u6837\u6267\u884c\u8fc7\u6765\u7684\u7ed3\u679c\u5c31\u4f1a\u5c11\u4e86\u4e00\u884c;<\/p>\n<p>\u3000\u3000\u5b9e\u4f8b2:\u4e24\u5206\u7b97\u6cd5<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($ip1num&gt;$ipNum || $ip2num&lt;$ipNum)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u8fd9\u662fdiscuz\u91cc\u9762\u53d6\u5f97ip\u5730\u5740\u5bf9\u5e94\u7684\u771f\u5b9e\u5730\u5740\u7684function<\/p>\n<p>\u3000\u3000\u9644\u4ef6\u91cc\u9762\u6709\u8fd9\u4e2afunction\u7684\u6587\u4ef6\u5305<\/p>\n<p>\u3000\u3000\u7b80\u5355\u7684\u62c6\u6210<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($a&gt;1 || $b &lt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u518d\u62c6<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($a &gt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($b&lt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u5982\u679c$a \u662f\u5148\u6709\u503c\u7684\u60c5\u51b5\u4e0b\uff0c<\/p>\n<p>\u3000\u3000\u5982\u679c$a =1;<\/p>\n<p>\u3000\u3000\u90a3\u6837\u5c31\u6267\u884c\u4e0d\u4e0b\u53bb\uff0c\u6761\u4ef6\u4e0d\u6210\u7acb<\/p>\n<p>\u3000\u3000\u6216\u8005$a =2;<\/p>\n<p>\u3000\u3000\u8fd9\u6837\u5c31\u65e0\u9650\u5faa\u73af\u4e86;<\/p>\n<p>\u3000\u3000\u91cd\u70b9<\/p>\n<p>\u3000\u3000\u5982\u679c$a\u6ca1\u6709\u5148\u9644\u503c<\/p>\n<p>\u3000\u3000\u521a\u5f00\u59cb\u6211\u4e00\u76f4\u4ee5\u4e3a\u662f\u9519\u8bef\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u4ed6\u4e0d\u4f1a\u6709\u9519\u8bef\uff0c<\/p>\n<p>\u3000\u3000\u8fd9\u662fphp\u4e0d\u540c\u7684\u5730\u65b9<\/p>\n<p>\u3000\u3000\u7b80\u5355\u901a\u8fc7\u4e00\u4e2a\u7a0b\u5e8f\u6d4b\u8bd5\u4e00\u4e0b<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$i =0;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($a&lt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$i++;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000if(microtime(true)- $time1 &gt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000echo $i;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000$a =1;<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000?&gt;<\/span><\/p>\n<p>\u3000\u3000\u8fd0\u884c\u7ed3\u679c<\/p>\n<p>\u3000\u3000272487;<\/p>\n<p>\u3000\u3000while($a &lt;1)<\/p>\n<p>\u3000\u3000\u4ed6\u4f1a\u4e00\u76f4\u6267\u884c\uff0c\u76f4\u5230\u7a0b\u5e8f\u91cc\u9762\u62ec\u53f7\u91cc\u9762\u91cd\u65b0\u5f97\u5230\u4e00\u4e2a\u503c$a =1;<\/p>\n<p>\u3000\u3000$a&lt;1\u4e0d\u6210\u7acb\uff0c\u4ed6\u624d\u4f1a\u505c\u6b62\u8fd0\u884c;<\/p>\n<p>\u3000\u3000\u6240\u4ee5<\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000while($a&gt;1 || $b &lt;1)<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000{<\/span><\/p>\n<p><span style=\"color: rgb(0,128,0)\">\u3000\u3000}<\/span><\/p>\n<p>\u3000\u3000\u7684\u7406\u89e3\u662f\u5f53\u62ec\u53f7\u5185\u90e8\u6267\u884c\u5230$a&lt;=1\u540c\u65f6$b&gt;=1\u4e24\u4e2a\u6761\u4ef6\u5206\u6210\u6210\u7acb\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u624d\u4e2d\u6b62\u6267\u884c<\/p>\n<p>\u3000\u3000\u8fd9\u6837\u5c31\u662f\u53cc\u5206\u7b97\u6cd5\u4e86<\/p>\n<p>\u3000\u3000\u5982\u679c\u8fd9\u4e24\u4e2a\u90fd\u7406\u89e3\u7684\u8bdd\uff0c\u57fa\u672c\u4e0awhile\u5c31\u975e\u5e38\u6e05\u695a\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>while\u662fphp\u91cc\u9762\u7528\u7684\u6700\u591a\u7684\u4e00\u4e2a\u51fd\u6570\uff0c\u4f46\u662f\u89c2\u5bdf\u4e86\u5f88\u4e45\uff0c\u4f46\u662f\u5f88\u591a\u4eba\u7528\u4e60\u60ef\u4e86\uff0c\u5e76\u4e0d\u77e5\u9053\u91cc\u9762\u662f\u600e\u4e48\u56de\u4e8b\uff0c\u53ea\u662f\u4e60\u60ef\u6027\u6253\u4e0a\u53bb;<\/p>\n<p>\u3000\u3000\u5148\u6d4b\u4e00\u4e0b\u4e00\u79d2\u4e2d\uff0cwhile\u53ef\u4ee5\u8fd0\u884c\u591a\u5c11\u6b21\u5faa\u73af;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"tcat":[],"_links":{"self":[{"href":"http:\/\/www.qyuef.com\/index.php?rest_route=\/wp\/v2\/posts\/459"}],"collection":[{"href":"http:\/\/www.qyuef.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qyuef.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459"}],"version-history":[{"count":0,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=\/wp\/v2\/posts\/459\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.qyuef.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459"},{"taxonomy":"tcat","embeddable":true,"href":"http:\/\/www.qyuef.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftcat&post=459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}