{"id":2985,"date":"2014-06-30T23:37:07","date_gmt":"2014-06-30T15:37:07","guid":{"rendered":"https:\/\/sdeno.com\/?p=2985"},"modified":"2016-07-06T11:51:52","modified_gmt":"2016-07-06T03:51:52","slug":"php%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=2985","title":{"rendered":"php\u7b14\u8bb0"},"content":{"rendered":"<p><span style=\"color: #ff0000;\">*<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/phpfh.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:551px\"><div style=\"padding-top:7.2595281306715%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"551\" height=\"40\" class=\"alignnone size-full wp-image-3254 lazyload\" title=\"phpfh\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/phpfh.jpg\" alt=\"phpfh\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/phpfh.jpg 551w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/phpfh-300x21.jpg 300w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\"><\/figure><\/a><\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u53d8\u91cf\u548c\u5e38\u91cf\u533a\u5206<\/span>\u5927\u5c0f\u5199<br \/>\n$a =10;<br \/>\n$A =20;<br \/>\n\u4ee5\u4e0a\u53d8\u91cf\u540d\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684.<br \/>\necho Echo \u4e0d\u533a\u5206\u5927\u5c0f\u5199<br \/>\n\u53ef\u53d8\u53d8\u91cf<br \/>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php1.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:154px\"><div style=\"padding-top:83.766233766234%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"154\" height=\"129\" class=\"alignnone size-full wp-image-2988 lazyload\" title=\"php1\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php1.jpg\" alt=\"php1\"><\/figure><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u53d8\u91cf\u8d4b\u503c<\/span>[\u4f20\u9012\u8d4b\u503c(\u72ec\u7acb)\uff0c\u5f15\u7528\u8d4b\u503c\uff08\u5173\u8054)]<br \/>\n$one=10; \/\/10\u8d4b\u503c\u8ddfone<br \/>\n$two=$one \/\/one\u8d4b\u503c\u7ed9two,\u5373\u4f7f\u6539\u53d8one\u7684\u503c\uff0ctwo\u7684\u503c\u4e0d\u4f1a\u53d8<\/p>\n<p>$two=&amp;$one \/\/\u5f15\u7528\u8d4b\u503c \u6539\u53d8one\u6216\u8005two\u5c31\u662f\u7b49\u4e8e\u6539\u53d8\u4e86\u53e6\u4e00\u4e2a\u53d8\u91cf\u3002<\/p>\n<p>PHP\u53d8\u91cf\u7c7b\u578b\u548cJS\u4e00\u6837\u90fd\u662f\u4e0d\u7528\u53bb\u58f0\u660e\u6307\u5b9a\u7684\u7c7b\u578b\uff0c\u53ea\u8981\u770b\u503c\u6765\u5224\u65ad\u53d8\u91cf\u7684\u7c7b\u578b\u3002<br \/>\n\u53d8\u91cf\u7c7b\u578b<br \/>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php2.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:254px\"><div style=\"padding-top:89.370078740157%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"254\" height=\"227\" class=\"alignnone size-full wp-image-2989 lazyload\" title=\"php2\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php2.jpg\" alt=\"php2\"><\/figure><\/a><\/p>\n<p>\u67e5\u770b\u7c7b\u578bvar_dump($a);<\/p>\n<p>\u5355\u5f15\u53f7 \u548c \u53cc\u5f15\u53f7 \u7684\u533a\u522b\uff0c<br \/>\n\u5982\u679c\u53ea\u662f\u5355\u7eaf\u7684\u8f93\u51fa\u5b57\u7b26\u4e32\u548c\u8f6c\u4e49\\&#8217; \\\\\u5c31\u4f7f\u7528\u5355\u5f15\u53f7\uff0c\u5426\u5219\u5c31\u662f\u7528\u53cc\u5f15\u53f7\uff0c<br \/>\n\u53cc\u5f15\u53f7\u53ef\u4ee5\u540c\u65f6\u8f93\u51fa\u5b57\u7b26\u4e32\u91cc\u9762\u7684\u53d8\u91cf\u548c\u591a\u4e2a\u8f6c\u4e49\u5b57\u7b26\u4e3a\u4ec0\u4e48\u4e0d\u4f7f\u7528\u5462\uff1f\u56e0\u4e3a\u4f1a\u5360\u7528\u8d44\u6e90\u3002<br \/>\n<span style=\"color: #ff0000;\">\u6570\u636e\u7c7b\u578b\u4e4b\u95f4\u8f6c\u6362<\/span><br \/>\nsetType(\u53d8\u91cf,\u7c7b\u578b)<br \/>\n\u4f8b\u5982\uff1a<br \/>\n$str=&#8221;100.234abc&#8221;;<br \/>\nsetType($str,int); \/\/\u8f93\u51fa\u7684\u503c\u662f100\uff0c\u8fd9\u4e2a\u51fd\u6570\u662f\u5728\u539f\u7c7b\u578b\u4e0a\u6539\u53d8\u3002<\/p>\n<p>$a=(int)$str; \/\/\u8fd9\u4e2a\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u91cd\u65b0\u8f6c\u578b\u8d4b\u503c\u7ed9$a,\u539f\u7c7b\u578b$str\u4e0d\u4f1a\u53d8\u3002<\/p>\n<p>$a=intval($str); \/\/ \u6b64\u65b9\u6cd5\u8ddf\u7b2c\u4e8c\u4e2a\u4e00\u6837\u90fd\u662f\u7c7b\u578b\u4e34\u65f6\u8f6c\u5316\u3002<\/p>\n<p>\u7c7b\u578b\u4e34\u65f6\u8f6c\u5316\u7684\u6709\uff1aintval()\u3001 floatval() \u3001strval()<br \/>\n\u4ee5\u4e0a\u90fd\u662f\u5f3a\u5236\u8f6c\u6362<br \/>\n\u56e0\u4e3aPHP\u662f\u5f31\u7c7b\u578b\u7684\u8bed\u8a00\u4e0d\u8003\u8651\u7c7b\u578b\u8f6c\u5316\u5c31\u53ef\u4ee5\u76f8\u52a0\u4f8b\u5982<br \/>\n$a=10;<br \/>\n$b=&#8221;100abc&#8221;;<br \/>\n$c=true;<br \/>\n$d=12.34;<br \/>\n$sum=$a+$b+$c+$d; \/\/\u76f8\u52a0\u7684\u8bddPHP\u4f1a\u5c06\u5176\u4ed6\u7c7b\u578b\u81ea\u52a8\u8f6c\u6362\u6210\u6570\u5b57\u578b\uff0c\u8fd9\u5c31\u662fPHP\u5f00\u53d1\u5feb\u7684\u539f\u56e0\u3002<br \/>\n<span style=\"color: #ff0000;\">\u8ddf\u53d8\u91cf\u6709\u5173\u7684PHP\u5185\u7f6e\u51fd\u6570<\/span>\uff0c\u5982\u4e0b<br \/>\nisset() \/\/\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u5426\u5b58\u5728\uff0c\u4e0d\u7ba1\u53d8\u91cf\u662f\u4e0d\u662f\u7a7a\u90fd\u7b97\u5b58\u5728\u3002\uff08null\u4e5f\u7b97\u53d8\u91cf\u4e0d\u5b58\u5728\uff09<br \/>\nempty() \/\/\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u4e0d\u662f\u4e3a\u7a7a\uff0c\u4e3a\u7a7a\u7684\u8bdd\u8fd4\u56detrue\u5426\u5219false\u3002\uff08&#8221;&#8221;\u30010\u3001&#8221;0&#8243;\u3001null\u3001false\u3001array()\u3001var $var\u90fd\u4e3a\u7a7a\uff09<br \/>\nunset();\/\/\u5220\u9664\u53d8\u91cf\u3002<br \/>\nsetType()\/\/\u7c7b\u578b\u4e4b\u95f4\u5f3a\u5236\u8f6c\u6362<br \/>\nvar_dump()\/\/\u67e5\u770b\u7c7b\u578b\uff08\u7f29\u5199\uff09\uff0c\u8fd9\u4e2a\u65e2\u80fd\u770b\u5230\u7c7b\u578b\u4e5f\u80fd\u770b\u5230\u503c<br \/>\ngetType()\/\/\u67e5\u770b\u7c7b\u578b\uff08\u6269\u5199\uff09\uff0c\u53ea\u80fd\u770b\u51fa\u7c7b\u578b\u3002<br \/>\n<span style=\"color: #ff0000;\">\u5224\u65ad\u53d8\u91cf\u7c7b\u578b\u51fd\u6570<\/span>\uff08PHP\u5f3a\u5927\u5c31\u5728\u4e8e\u5185\u7f6e\u51fd\u6570\u592a\u591a\u4f7f\u7528\u8d77\u6765\u65b9\u4fbf\uff09<br \/>\nis_bool();<br \/>\nis_int() is_integer() is_long()<br \/>\nis_string()<br \/>\nis_float() is_double() is_real()<br \/>\nis_array()<br \/>\nis_object()<br \/>\nis_resource() \/\/\u5224\u65ad\u53d8\u91cf\u662f\u5426\u662f\u8d44\u6e90\u7c7b\u578b<br \/>\nis_null()<\/p>\n<p>is_scalar() \/\/\u5224\u65ad\u662f\u5426\u662f \u6574\u5f62 \u6d6e\u70b9\u578b \u5b57\u7b26\u4e32<br \/>\nis_callable()\/\/\u5224\u65ad\u662f\u5426\u662f\u6709\u6548\u7684\u51fd\u6570\u540d<br \/>\nis_numeric()\/\/\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u4e0d\u662f\u6570\u5b57\u578b<br \/>\n<span style=\"color: #ff0000;\">\u5b9a\u4e49\u4e00\u4e2a\u5e38\u91cf<\/span>\u7684\u65b9\u6cd5<br \/>\ndefine(&#8220;\u5e38\u91cf\u540d&#8221;,&#8221;\u5e38\u91cf\u503c&#8221;);<\/p>\n<p>\u5224\u65ad\u4e00\u4e2a\u5e38\u91cf\u662f\u5426\u5b58\u5728\u7528defined(&#8220;\u5e38\u91cf\u540d&#8221;);<\/p>\n<p>\u5e38\u91cf\u503c\u6c38\u8fdc\u4e0d\u4f1a\u53d8\uff0c\u4e5f\u4e0d\u80fd\u88abunset()\u5220\u9664\u662f\u5168\u5c40\u53d8\u91cf\uff0c\u8d4b\u503c\u53ea\u80fd\u662f\u6807\u91cf\uff08int,float,bool,string\uff09<br \/>\n\u5e38\u91cf\u7684\u503c\u4e00\u65e6\u58f0\u660e\u4e86\u4e5f\u4e0d\u80fd\u6539\u3002<br \/>\n\u8fd0\u7b97\u7b26&#8212;&#8212;<\/p>\n<p>%\u53d6\u4f59\u6570<\/p>\n<p>.\u5728PHP\u4e2d<span style=\"color: #ff0000;\">\u5b57\u7b26\u4e32\u8fde\u63a5<\/span>\u7528\u7684\u662f.\u800c\u5728js\u4e2d\u7528\u7684\u662f+\u3002<br \/>\n+= -= *= \/= %= \/\/\u4f8b\u5982 $a+=10; $a=$a+10;<\/p>\n<p>.= \/\/\u4f8b\u5982 $a.=&#8221;abc&#8221; $a=$a.&#8221;abc&#8221;;<\/p>\n<p>$str='&lt;table&gt;&#8217;;<br \/>\n$str.='&lt;\/table&gt;&#8217;; \/\/\u8f93\u51fa\u7ed3\u679c\u5c31\u662f&lt;table&gt;&lt;\/table&gt;<br \/>\n\u4f4d\u8fd0\u7b97\u7b26 \u5728JS \u548cPHP \u51e0\u4e4e\u5f88\u5c11\u7528\u5230<\/p>\n<p>&#8220;\u7b26\u53f7\u53ef\u4ee5\u91cc\u9762\u53ef\u4ee5\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u7136\u540e\u5c06\u7ed3\u679c\u8d4b\u503c\u7ed9\u4e00\u4e2a\u53d8\u91cf<br \/>\n\u4f8b\u5982<br \/>\n$str=`ipconfig \/all`;<\/p>\n<p>&nbsp;<\/p>\n<p>\u6587\u4ef6\u548c\u6587\u4ef6\u76ee\u5f55\u7684\u76f8\u5173\u64cd\u4f5c<\/p>\n<p>echo basename(&#8216;c:\\www\\1.php&#8217;) \u00a0 \/\/\u53ea\u83b7\u53d6\u6587\u4ef6\u540d 1.php<\/p>\n<p>echo dirname(&#8216;c:\\www\\1.php&#8217;) \u00a0\/\/\u83b7\u53d6\u8def\u5f84 \u00a0c:\\www\\<\/p>\n<p>print_r(pathinfo(&#8216;c:\\www\\1.php&#8217;)) \u00a0 \/\/\u83b7\u5f97\u6b64\u6587\u4ef6\u7684 \u7edd\u5bf9\u8def\u5f84\u3001\u683c\u5f0f\u3001\u540d\u79f0\u3002<\/p>\n<p>realpath(&#8216;1.php&#8217;) \u00a0\/\/ \u83b7\u53d6\u5230\u6b64\u6587\u4ef6\u6240\u5728\u7684\u7edd\u5bf9\u8def\u5f84 c:\\www\\1.php<\/p>\n<p>\u9b54\u6cd5\u5e38\u91cf<\/p>\n<p>__FILE__ \u00a0\/\/ \u83b7\u53d6\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84\u4f8b\u5982 \u00a0c:\/www\/2.php<\/p>\n<p>&nbsp;<\/p>\n<p>\u5faa\u73af<\/p>\n<p>\u8303\u56f4\u5224\u65ad\u4f7f\u7528if else<br \/>\n\u5355\u4e2a\u503c\u5224\u65ad\u4f7f\u7528switch<\/p>\n<p>break \/\/\u9000\u51fa\u5b83\u6240\u5728\u7684\u5faa\u73af\u4f53\uff0c\u5faa\u73af\u4f53\u540e\u9762\u7684\u4ee3\u7801\u8fd8\u6267\u884c<\/p>\n<p>exit \u00a0\/\/\u5728\u5b83\u540e\u9762\u7684\u4ee3\u7801\u4e00\u6982\u90fd\u4e0d\u6267\u884c<\/p>\n<p>continue \/\/\u9000\u51fa\u6b64\u65f6\u523b\u7684\u5faa\u73af\u7ee7\u7eed\u540e\u9762\u7684\u5faa\u73af<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u968f\u673a\u6570<\/span><\/p>\n<p>echo mt_rand(0,100); \u00a0\/\/\u5305\u62ec0\u548c100\u76840\u5230100\u7684\u968f\u673a\u6574\u6570\u3002<\/p>\n<p>\u683c\u5f0f\u5316\u6570\u636e<\/p>\n<p>$i=123456.789;<\/p>\n<p>$b=number_format($i,2); \u00a0\/\/\u5bf9$i\u53d8\u91cf\u683c\u5f0f\u5316\uff0c\u4fdd\u75592\u4f4d\u5c0f\u6570\u6ca1\u6709\u7684\u8bdd\u5c31.00\u8865\u5145<\/p>\n<p>$b \u00a0\/\/123,456.78<\/p>\n<p><span style=\"color: #ff0000;\">\u6570\u5b66\u51fd\u6570<\/span><\/p>\n<p>abs() \u00a0 \/\/\u7edd\u5bf9\u503c<\/p>\n<p>floor() \u00a0\/\/\u820d\u53bb\u5c0f\u6570\u4fdd\u7559\u6574\u6570<\/p>\n<p>ceil() \u00a0 \/\/\u53ea\u8981\u5c0f\u6570\u70b9\u4e0d\u662f0\uff0c\u90fd\u4f1a\u5411\u6574\u6570\u52a01<\/p>\n<p>round() \/\/\u56db\u820d\u4e94\u5165<\/p>\n<p>min() \u00a0\/\/\u6c42\u6700\u5c0f\u6570<\/p>\n<p>max() \u00a0\/\/\u6c42\u6700\u5927\u6570<\/p>\n<p>\u4ee5\u4e0a\u662f\u5e38\u7528\u7684\uff0c\u5176\u4ed6\u7684\u8fd8\u6709\u5f88\u591a\u9700\u8981\u81ea\u5df1\u67e5\u8d44\u6599\u4e86<\/p>\n<p><span style=\"color: #ff0000;\">\u51fd\u6570<\/span><br \/>\n\u51fd\u6570\u4e2d\u672b\u5c3e\u52a0\u4e0areturn $str,\u51fd\u6570\u7684\u503c\u5c31\u4f1a\u8fd4\u56de\u7ed9\u8c03\u7528\u5904\uff0c\u8c03\u7528\u5c31\u6210\u4e86\u4e00\u4e2a\u503c,\u8fd9\u6837\u53ef\u4ee5\u8f93\u5165\u6570\u636e\u5e93\u3002<br \/>\n\u4f8b\u5982<br \/>\nfunction table(){<br \/>\n$str='&lt;table&gt;&lt;\/table&gt;&#8217;;<br \/>\nreturn $str;<br \/>\necho &#8216;1111&#8217;; \/\/\u5728return\u540e\u9762\u5199\u4ee3\u7801\u65e0\u6548,\u540c\u65f6\u4e5f\u53ef\u4ee5\u4f7f\u7528return\u5f53\u4f5c\u51fd\u6570\u7684\u7ed3\u675f\u8bed\u53e5\u3002<br \/>\n}<\/p>\n<p>echo table(); \/\/table()\u5c31\u662f\u4e00\u4e2a\u503c\u4e86\u3002<br \/>\necho table().&#8217;\u4f60\u597d&#8217;; \/\/\u5982\u679c\u662f\u503c\u6570\u5b57\u4e5f\u53ef\u4ee5\u53c2\u4e0e\u8fd0\u7b97<br \/>\n\u51fd\u6570\u4e2d\u8981\u4f7f\u7528\u51fd\u6570\u4ee5\u5916\u7684\u5168\u5c40\u53d8\u91cf\u5c31\u8981\u4f7f\u7528global,\u4f8b\u5982\u3002<br \/>\n$a=10;<br \/>\nfunction table(){<br \/>\nglobal $a; \/\/\u8fd9\u6837\u624d\u80fd\u4f7f\u7528\u4e0a\u5168\u5c40\u7684$a<br \/>\n$a+=10;<br \/>\n}<br \/>\nstatic \u5728\u51fd\u6570\u4e2d\u53d8\u91cf\u4e2d\u58f0\u660e\u6b64\u65f6\u7684\u53d8\u91cf\u5c31\u76f8\u5f53\u4e8e\u8fd9\u4e2a\u51fd\u6570\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u6b64\u53d8\u91cf\u4f1a\u5171\u7528\u3002<br \/>\n\u4f8b\u5982\uff0c<br \/>\nfunction test(){<br \/>\nstatic $a=0;<br \/>\n$a++;<br \/>\necho $a.&#8221;&lt;br&gt;&#8221;;<br \/>\n}<\/p>\n<p>test(); \/\/ a=1<br \/>\ntest(); \/\/ a=2<br \/>\ntest(); \/\/ a=3<\/p>\n<p>\u51fd\u6570\u91cc\u7684\u53c2\u6570\u53d8\u91cf\u548c\u51fd\u6570\u5916\u7684\u53d8\u91cf\u4e0d\u4f1a\u6709\u51b2\u7a81\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u53d8\u91cf\u51fd\u6570\uff0c\u5c31\u662f\u628a\u51fd\u6570\u8d4b\u503c\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u7136\u540e\u53d8\u91cf\u62ec\u53f7\u91cc\u9762\u7a7f\u53c2\u6570\u3002<br \/>\n\u4f8b\u5982\uff0c<br \/>\nfunction one($a,$b){<br \/>\nreturn $a+$b;<br \/>\n}<\/p>\n<p>function two($a,$b){<br \/>\nreturn $a*$b;<br \/>\n}<\/p>\n<p>$var=one; \/\/\u81ea\u52a8\u5bfb\u627e \u51fd\u6570\u540d\u662fone\u7684\u51fd\u6570<br \/>\n$var=&#8221;two&#8221;; \/\/\u81ea\u52a8\u5bfb\u627e \u51fd\u6570\u540d\u662ftwo\u7684\u51fd\u6570<\/p>\n<p>echo $var(3,4); \/\/\u53ef\u4ee5\u8fd9\u6837\u7a7f\u53c2\u6570<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e3a\u51fd\u6570\u8bbe\u7f6e\u9ed8\u8ba4\u53c2\u6570<\/p>\n<p>function($a=10){ \u00a0 \/\/\u8bbe\u7f6e\u9ed8\u8ba4\u53c2\u6570<\/p>\n<p>return $a;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u7ec4<\/p>\n<p>\u6570\u7ec4\u7684\u4e00\u4e9b\u7279\u6027<br \/>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php31.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:353px\"><div style=\"padding-top:71.104815864023%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"353\" height=\"251\" class=\"alignnone size-full wp-image-2993 lazyload\" title=\"php3\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php31.jpg\" alt=\"php3\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php31.jpg 353w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php31-300x213.jpg 300w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\"><\/figure><\/a><br \/>\n1\uff0c\u5982\u679c\u6570\u7ec4\u7d22\u5f150\u81ea\u5b9a\u4e49\u5728\u540e\u9762\uff0c\u90a3\u4e48\u7d22\u5f150\u524d\u9762\u7684\u6570\u7ec4\u5143\u7d20\u90fd\u6ca1\u5ffd\u7565\u3002<br \/>\n2\uff0c\u81ea\u5b9a\u4e49\u6570\u7ec4\u7d22\u5f15\uff0c\u6570\u7ec4\u540e\u9762\u7684\u7d22\u5f15\u9ed8\u8ba4\u63a5\u7740\u6700\u5927\u4e00\u4e2a\u7d22\u5f15\u5f00\u59cb\u3002<br \/>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php4.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:641px\"><div style=\"padding-top:33.073322932917%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"641\" height=\"212\" class=\"alignnone size-full wp-image-2994 lazyload\" title=\"php4\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php4.jpg\" alt=\"php4\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php4.jpg 641w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php4-300x99.jpg 300w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php4-624x206.jpg 624w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\"><\/figure><\/a><\/p>\n<p>\u53ef\u4ee5\u81ea\u5b9a\u4e49\u7d22\u5f15\uff0c\u5982\u679c\u5176\u4ed6\u6ca1\u6709\u81ea\u5b9a\u4e49\u7684\u7d22\u5f15\u5c31\u9ed8\u8ba4\u662f0\u5f00\u59cb<br \/>\n\u6570\u7ec4\u4e2d\u52a0\u5165\u6570\u7ec4<br \/>\n$user =array(array(),array(),array());<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php\u7b14\u8bb0.txt\">php\u7b14\u8bb0<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u7ec4\u904d\u5386<\/p>\n<p>1,for\u5faa\u73af\uff08\u6570\u7ec4\u7684\u7d22\u5f15\u5fc5\u987b\u662f\u6570\u5b57\u548c\u6709\u89c4\u5f8b\uff0cPHP\u4e2d\u4e0d\u63a8\u8350\u4f7f\u7528\uff09<br \/>\n2\uff0cforeach php\u4e2d\u63a8\u8350\u4f7f\u7528<br \/>\nforeach(\u6570\u7ec4\u53d8\u91cf as \u81ea\u5b9a\u4e49\u53d8\u91cf){<br \/>\n\u5faa\u73af\u6b21\u6570\u7531\u6570\u7ec4\u7684\u5143\u7d20\u4e2a\u6570\u786e\u5b9a\uff1b<br \/>\n\u6bcf\u6b21\u5faa\u73af\u90fd\u4f1a\u5c06\u5c5e\u6027\u503c\u8d4b\u503c\u7ed9\u81ea\u5b9a\u4e49\u53d8\u91cf\uff1b<br \/>\n}<\/p>\n<p>foreach(\u6570\u7ec4\u53d8\u91cf as \u81ea\u5b9a\u4e49\u7d22\u5f15\u53d8\u91cf=&gt;\u81ea\u5b9a\u4e49\u5c5e\u6027\u503c\u53d8\u91cf){<br \/>\n\u6bcf\u6b21\u5faa\u73af\u90fd\u4f1a\u81ea\u52a8\u5c06\u6570\u7ec4\u7684\u7d22\u5f15\u548c\u5c5e\u6027\u503c \u8d4b\u503c\u7ed9\u81ea\u5b9a\u4e49\u7d22\u5f15\u53d8\u91cf \u548c \u81ea\u5b9a\u4e49\u5c5e\u6027\u503c\u53d8\u91cf<br \/>\n}<\/p>\n<p>3\uff0cwhile() list() each() \u7ec4\u5408\u4f7f\u7528<\/p>\n<p>each(\u6570\u7ec4)<br \/>\n\u7b2c\u4e00\u6b21\u8c03\u7528\u8fd4\u56de\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5c5e\u6027\u548c\u5c5e\u6027\u503c\uff0c\u7ed3\u679c\u662f\u6570\u7ec4\uff0c\u56fa\u5b9a\u662f\u5c5e\u6027\u662f0\uff0c1\uff0ckey\uff0cvalue\uff0c<br \/>\n0,key\u662f\u5c5e\u6027<br \/>\n1,value\u662f\u5c5e\u6027\u503c<br \/>\n\u7b2c\u4e8c\u6b21\u8c03\u7528\u8fd4\u56de\u6570\u7ec4\u7b2c\u4e8c\u4e2a\u5c5e\u6027\u548c\u5c5e\u6027\u503c\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u5982\u679c\u7ee7\u7eed\u8c03\u7528\u8fd4\u56de\u7684\u5c31\u662ffalse\u3002<\/p>\n<p>\u6253\u5370\u7ed3\u679c\/\/Array([1]=&gt;\u503c [value]=&gt;\u503c [0]=&gt;\u7d22\u5f15 [key]=&gt;\u7d22\u5f15 );<\/p>\n<p>&nbsp;<\/p>\n<p>list(\u6570\u7ec4)<\/p>\n<p>list($a,$b,$c)=$array \/\/ $arry\u6570\u7ec4\u53ea\u80fd\u662f\u4e0b\u6807\u4e3a\u6570\u5b57\u7684\u624d\u80fd\u4f7f\u7528list();<br \/>\n\u4e5f\u5c31\u662f\u8bf4\u4f8b\u5982 $array=array(&#8216;age&#8217;=&gt;19,&#8217;name&#8217;=&gt;&#8217;\u5c0f\u9648&#8217;) \u8fd9\u6837\u7684\u6570\u7ec4\u5c31\u4e0d\u80fd\u8d4b\u503c\u7ed9list()<br \/>\nlist()=\u6570\u7ec4 \/\/\u5c06\u6570\u7ec4\u8d4b\u503c\u7ed9list()\u51fd\u6570<br \/>\nlist($name,,$age)=array(&#8216;zhangsan&#8217;,10,&#8217;\u7537&#8217;); \/\/\u8981\u4e00\u4e00\u5bf9\u5e94 *list()\u53ea\u80fd\u63a5\u53d7\u7d22\u5f15\u662f\u6570\u5b57\u7684\uff0c\u5e76\u4e14\u6309\u6570\u5b57\u5c0f\u5230\u5927\u8d4b\u503c<br \/>\n\u4f8b\u5b50\u4e00\uff1a<br \/>\n$user=array(&#8220;id&#8221;=1,&#8221;name&#8221;=&gt;&#8221;zhangsan&#8221;,&#8221;age&#8221;=&gt;10,&#8221;sex&#8221;=&gt;&#8221;nan&#8221;);<br \/>\nlist($key,$value)=each($user); \/\/\u6253\u5370\u51fa Array([1]=&gt;1 [value]=&gt;1 [0]=&gt;id [key]=&gt;id );<br \/>\n\/\/\u4f46\u662flist()\u7684\u53c2\u6570\u53ea\u80fd\u63a5\u53d7\u6570\u5b57\uff0c\u867d\u7136\u5148\u6253\u5370\u51fa[1]=&gt;1\u5728\u5230[0]=&gt;id\uff0c<br \/>\n\u8d4b\u503c\u987a\u5e8f\u662f[0]=&gt;id\u5148\u8d4b\u503c\u7ed9$key\uff0c[1]=&gt;1\u5728\u8d4b\u503c\u7ed9$value<\/p>\n<p>\u4f8b\u5b50\u4e8c\uff1a<br \/>\n$ip=&#8221;192.168.1.128&#8243;;<br \/>\n$ips=explode(&#8220;.&#8221;,$ip); \/\/\u5c06IP\u4ee5\u70b9\u5206\u5272\u6210\u4e3a\u4e00\u4e2a\u6570\u7ec4\u3002<br \/>\nlist(,,,)=explode(&#8220;.&#8221;,$ip);<br \/>\n3\u4e2a\u51fd\u6570\u7ec4\u5408\u4f7f\u7528\u4f8b\u5b50\uff1a<br \/>\n$user=array(&#8220;id&#8221;=1,&#8221;name&#8221;=&gt;&#8221;zhangsan&#8221;,&#8221;age&#8221;=&gt;10,&#8221;sex&#8221;=&gt;&#8221;nan&#8221;);<br \/>\nwhile(list($key,$value)=each($user)){ \/\/\u5229\u7528while\u4e00\u76f4\u5faa\u73af\u76f4\u5230each\u6267\u884c\u5230false\u7684\u65f6\u5019\u8df3\u51fawhile\u5faa\u73af,<br \/>\necho $key.&#8221;&#8212;&#8211;&#8220;.$valu; \/\/each\u9010\u4e2a\u8c03\u7528\u8d4b\u503c\u7ed9list,\u601d\u8def\u5728\u4f8b\u5b50\u4e00\u3002<br \/>\n}<\/p>\n<p>\u63a7\u5236\u6570\u7ec4\u6267\u884c\u6b65\u9aa4<br \/>\nnext(\u6570\u7ec4) \/\/ \u6267\u884c\u4e00\u6b21\u6307\u9488\u6307\u5411\u4e0b\u4e00\u6b65\u3002<br \/>\nprev(\u6570\u7ec4)<br \/>\nreset(\u6570\u7ec4) \/\/\u8fd4\u56de\u7b2c\u4e00\u4e2a\u6307\u9488\u521d\u59cb\u5316\u610f\u601d<br \/>\nend(\u6570\u7ec4)<br \/>\ncurrent(\u6570\u7ec4) \/\/\u83b7\u53d6\u5f53\u524d\u6570\u7ec4\u7684\u5c5e\u6027\u503c\uff0c\u6267\u884c\u591a\u6b21\u6307\u9488\u4e0d\u53d8\u3002<br \/>\nkey(\u6570\u7ec4) \/\/\u83b7\u53d6\u5f53\u524d\u6570\u7ec4\u7684\u7d22\u5f15<\/p>\n<p>&nbsp;<\/p>\n<p>!!\u7528\u6cd5\u5176\u5b9e\u5c31\u662f\u5c06\u771f\u5b9e\u5b58\u5728\u7684\u6570\u636e\u8f6c\u5316\u6210\u4e3a\u5e03\u5c14\u503c \u548cJS\u7528\u6cd5\u4e00\u6837<br \/>\n\u4f8b\u5982<br \/>\necho each($array); \/\/\u663e\u793aarray \u8bf4\u660e\u662f\u6709\u6570\u636e\u7684 \u4e3atrue<\/p>\n<p>echo !each($array); \/\/ null\u7a7a\u767d\u4e0d\u663e\u793a\u6570\u636e<\/p>\n<p>echo !!each($array); \/\/ 1 \u6b64\u65f6\u5c31\u8f6c\u5316\u6210\u4e86\u5e03\u5c14\u503c<\/p>\n<p>\u5faa\u73af\u6570\u7ec4\u91cc\u7684\u6570\u7ec4\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/each_array.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:533px\"><div style=\"padding-top:93.996247654784%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"533\" height=\"501\" class=\"alignnone size-full wp-image-3582 lazyload\" title=\"each_array\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/each_array.jpg\" alt=\"each_array\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/each_array.jpg 533w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/each_array-300x281.jpg 300w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\"><\/figure><\/a>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php2.txt\">php2<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u7ec4\u7684\u76f8\u5173\u5904\u7406\u51fd\u6570<\/p>\n<p>\u7d22\u5f15\/\u5c5e\u6027\u503c \u7684\u64cd\u4f5c<br \/>\n1\uff0carray_values(); \/\/\u5c06\u6570\u7ec4\u7684\u5c5e\u6027\u503c\u53d6\u51fa\u6765\u4ece\u65b0\u6392\u5217\u4e00\u4e2a\u7d22\u5f15\u4ece0\u5f00\u59cb\u7684\u65b0\u6570\u7ec4\u3002<\/p>\n<p>2\uff0carray_keys(); \/\/\u53d6\u51fa\u6570\u7ec4\u7684\u7d22\u5f15\u91cd\u65b0\u6392\u5217\u6210\u4e00\u4e2a\u6570\u7ec4\u7d22\u5f15\u53c8\u662f\u4ece0\u5f00\u59cb\u3002<br \/>\narray_keys(\u6570\u7ec4,&#8221;\u5c5e\u6027\u503c&#8221;,true) \/\/\u8fd9\u91cc\u7684\u586b\u5199\u5c5e\u6027\u503c\u5c31\u83b7\u53d6\u5230\u6b64\u5c5e\u6027\u503c\u7684\u7d22\u5f15\u6392\u5217\u6210\u4e00\u4e2a\u6570\u7ec4<br \/>\n\/\/\u7b2c3\u4e2a\u53c2\u6570\u9ed8\u8ba4\u662ffalse\uff0c\u5982\u679c\u5199true\u610f\u601d\u662f\u662f\u5426\u4e25\u683c\u6309\u7167\u7c7b\u578b\u5224\u65ad<\/p>\n<p>3\uff0cin_array(&#8220;\u5c5e\u6027\u503c&#8221;,\u6570\u7ec4,true) \/\/\u5224\u8bfb\u8fd9\u4e2a\u5c5e\u6027\u503c\u5728\u4e0d\u5728\u8fd9\u4e2a\u6570\u7ec4\u91cc\u9762\uff0c\u5728\u8fd4\u56detrue \u4e0d\u5728\u8fd4\u56defalse<br \/>\n\/\/\u7b2c\u4e09\u4e2a\u53c2\u6570\u4e3atrue,\u5c5e\u6027\u503c\u7684\u7c7b\u578b\u5c31\u5fc5\u987b\u4e25\u683c\u5339\u914d<\/p>\n<p>4\uff0carray_key_exists(&#8220;\u7d22\u5f15&#8221;,\u6570\u7ec4) \/\/\u5224\u65ad\u7d22\u5f15\u5728\u4e0d\u5728\u6570\u7ec4\u4e2d<\/p>\n<p>5\uff0carray_flip \/\/\u5c06\u6570\u7ec4\u4e2d\u7684 \u7d22\u5f15\u548c\u5c5e\u6027\u503c \u4ea4\u6362<\/p>\n<p>6\uff0carray_reverse(\u6570\u7ec4) \/\/\u6570\u7ec4\u91cc\u7684\u5143\u7d20\u987a\u5e8f\u98a0\u5012<\/p>\n<p>&nbsp;<\/p>\n<p>\u7edf\u8ba1\u6570\u7ec4\u5143\u7d20\u4e2a\u6570 \u548c \u5c5e\u6027\u503c\u7684\u552f\u4e00\u6027<br \/>\n1\uff0ccount(\u6570\u7ec4,1) \/\/\u7edf\u8ba1\u6570\u7ec4\u91cc\u9762\u7684\u5143\u7d20\u4e2a\u6570\uff0c\u5982\u679c\u52a0\u4e0a1\uff0c\u5c31\u4f1a\u5c06\u5143\u7d20\u4e3a\u6570\u7ec4\u7684\u5143\u7d20\u4e00\u6837\u7edf\u8ba1\u51fa\u6765\u3002<\/p>\n<p>2\uff0carray_count_values \/\/\u5206\u7c7b\u7edf\u8ba1\u6570\u7ec4\u91cc\u9762\u7684\u5c5e\u6027\u503c\u51fa\u73b0\u7684\u91cd\u590d\u6b21\u6570\uff0c\u8fd4\u56de\u7ed3\u679c\u662f\u6570\u7ec4\u3002<br \/>\n\u4f8b\u5982\u8fd4\u56de array( [linux]=&gt;2,[apache]=&gt;2 ); \/\/\u5c5e\u6027\u503c\u6210\u4e86\u7d22\u5f15\uff0c\u91cd\u590d\u4e2a\u6570\u6210\u4e86\u5c5e\u6027\u503c\u3002<\/p>\n<p>3\uff0carray_unique \/\/\u79fb\u9664\u6570\u7ec4\u4e2d\u91cd\u590d\u7684\u5c5e\u6027\u503c\uff0c\u4fdd\u7559\u539f\u6765\u6570\u7ec4\u4e0d\u53d8\u521b\u5efa\u65b0\u6570\u7ec4\u3002<br \/>\n\u6570\u7ec4\u5143\u7d20\u8fc7\u6ee4<\/p>\n<p>4\uff0cextract() \u00a0\/\/\u5c06\u6570\u7ec4\u7684\u7d22\u5f15\u8f6c\u6210\u53d8\u91cf\u3002<\/p>\n<p>\u4f8b\u5982$array=array(&#8216;wo&#8217;=&gt;&#8217;\u9648\u683c&#8217;);<\/p>\n<p>extract($array);<\/p>\n<p>echo $wo; \/\/\u9648\u683c<br \/>\n1\uff0carray_filter(\u6570\u7ec4,&#8221;\u51fd\u6570&#8221;)<br \/>\n\u4f8b\u5b50\uff1a<br \/>\n$arr=array(1,2,3,-4,4,5,-5,-12);<br \/>\n$arr1=array_filter($arr,&#8221;myfun&#8221;); \/\/\u5c06\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u4e00\u4e2a\u4e2a\u5e26\u5165\u51fd\u6570\u4e2d\uff0ctrue\u5c31\u91cd\u65b0\u8fd4\u56de\u6570\u7ec4false\u5c31\u5220\u9664\u3002<br \/>\nfunction myfun($n){<br \/>\nif($n&gt;0){<br \/>\nreturn true;<br \/>\n}else{<br \/>\nreturn false;<br \/>\n}<br \/>\n}<br \/>\n\u8fd4\u56de \/\/=array(1,2,3,4,5,-12);<br \/>\n2\uff0carray_walk() \u4f8b\u5b50\u8bf4\u660e<br \/>\n$arr=array(&#8220;os&#8221;=&gt;&#8221;linux&#8221;,&#8221;wb&#8221;=&gt;&#8221;apache&#8221;);<br \/>\narray_walk($arr,&#8221;myfun1&#8243;,&#8221;========&#8221;);<br \/>\nfunction myfun1($value,$key,$p){<br \/>\necho $key.$p.$value.&#8221;&lt;br&gt;&#8221;;<br \/>\n}<br \/>\n\u8fd4\u56de \/\/ os========linux<br \/>\nwb========apache<\/p>\n<p>array_walk($arr,&#8221;myfun1&#8243;);<br \/>\nfunction myfun1(&amp;$value,$key){ \/\/\u5c5e\u6027\u503c\u5904\u52a0\u4e86&amp;\u7b26\u53f7<br \/>\n$value=&#8221;ffffff&#8221;; \/\/\u7edf\u4e00\u5c06\u5168\u90e8\u7684\u5c5e\u6027\u503c\u90fd\u91cd\u65b0\u8d4b\u503c\u6210\u4e3affffff<br \/>\n}<br \/>\n\u8fd4\u56de \/\/ array(&#8220;os&#8221;=&gt;&#8221;ffffff&#8221;,&#8221;wb&#8221;=&gt;&#8221;ffffff&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>3,array_map() \/\/\u7edf\u4e00\u5728\u539f\u6765\u5c5e\u6027\u503c\u4e0a\u6dfb\u52a0\u76f8\u540c\u5185\u5bb9<br \/>\n$arr=array(&#8220;os&#8221;=&gt;&#8221;linux&#8221;,&#8221;wb&#8221;=&gt;&#8221;apache&#8221;);<br \/>\n$arr1=array_map(&#8220;myfun1&#8221;,$arr); \/\/\u5c06\u6570\u7ec4\u4e2d\u7684\u5c5e\u6027\u503c\u5e26\u5165\u51fd\u6570\u4e2d<br \/>\nfunction myfun1($n){<br \/>\nreturn &#8220;==&#8221;.$n.&#8221;==&#8221;;<br \/>\n}<br \/>\n\u8fd4\u56de \/\/ array(&#8220;os&#8221;=&gt;&#8221;==linux==&#8221;,&#8221;wb&#8221;=&gt;&#8221;==apache==&#8221;);<br \/>\n$arr=array(&#8220;os&#8221;=&gt;&#8221;linux&#8221;,&#8221;wb&#8221;=&gt;&#8221;apache&#8221;);<br \/>\n$arrr=array(&#8220;os&#8221;=&gt;&#8221;win&#8221;,&#8221;wb&#8221;=&gt;&#8221;iis&#8221;);<br \/>\n$arr1=array_map(&#8220;myfun1&#8221;,$arr,$arrr); \/\/\u4e24\u4e2a\u6570\u7ec4\u957f\u5ea6\u8981\u4e00\u6837<br \/>\nfunction myfun1($n,$t){<br \/>\nif($n==$t){<br \/>\nreturn &#8220;same&#8221;;<br \/>\n}<br \/>\nreturn &#8220;diff&#8221;;<br \/>\n}<\/p>\n<p>\u8fd4\u56de \/\/ array([0]=&gt;diff,[1]=&gt;diff);<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php3.txt\">php3<\/a><\/p>\n<p>\u6570\u7ec4\u7684\u6392\u5e8f\u51fd\u6570<\/p>\n<p>sort() \/\/\u6839\u636e\u503c\u5c0f\u5230\u5927\u6392\u5e8f (\u7d22\u5f15\u88ab\u6539\u53d8\u6210\u4ece0\uff0c1..)<\/p>\n<p>rsort() \/\/\u6839\u636e\u503c\u5927\u5230\u5c0f\u6392\u5e8f (\u7d22\u5f15\u88ab\u6539\u53d8\u6210\u4ece0\uff0c1..)<\/p>\n<p>ksort() \/\/\u6839\u636e\u7d22\u5f15\u503c\u5c0f\u5230\u5927\u6392\u5e8f \u5e76\u4fdd\u7559\u539f\u6765\u7684\u7d22\u5f15\u548c\u503c\u7684\u5173\u7cfb<\/p>\n<p>krsort() \/\/\u6839\u636e\u7d22\u5f15\u503c\u5927\u5230\u5c0f\u6392\u5e8f \u5e76\u4fdd\u7559\u539f\u6765\u7684\u7d22\u5f15\u548c\u503c\u7684\u5173\u7cfb<\/p>\n<p>asort() \/\/\u6839\u636e\u503c\u5c0f\u5230\u5927\u6392\u5e8f \u5e76\u4fdd\u7559\u539f\u6765\u7684\u7d22\u5f15\u548c\u503c\u7684\u5173\u7cfb<\/p>\n<p>arsort() \/\/\u6839\u636e\u503c\u5927\u5230\u5c0f\u6392\u5e8f \u5e76\u4fdd\u7559\u539f\u6765\u7684\u7d22\u5f15\u548c\u503c\u7684\u5173\u7cfb<\/p>\n<p>\u81ea\u7136\u6570\u6392\u5e8f<br \/>\nnatsort() \u533a\u5206\u5927\u5c0f\u5199<br \/>\nnatcasesort() \u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/p>\n<p>\u4f8b\u5982<br \/>\n$data=array(&#8220;file1.txt&#8221;,&#8221;file11&#8243;,&#8221;file2.txt&#8221;,&#8221;file22.txt&#8221;);<br \/>\n\u5982\u679c\u4f7f\u7528\u666e\u901a\u7684\u6392\u5e8f\u4f8b\u5982\u662fsort()\u7ed3\u679c\u662f<br \/>\n(&#8220;file1.txt&#8221;,&#8221;file11&#8243;,&#8221;file2.txt&#8221;,&#8221;file22.txt&#8221;)<br \/>\nfile11\u6392\u5728\u4e86file2\u540e\u9762\u663e\u7136\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684<br \/>\n\u5982\u679c\u4f7f\u7528natsort()\uff0c\u6392\u5e8f\u7ed3\u679c\u4f1a\u6b63\u5e38\u3002<br \/>\n(&#8220;file1.txt&#8221;,&#8221;file2&#8243;,&#8221;file11.txt&#8221;,&#8221;file22.txt&#8221;)<br \/>\n\u5982\u679c\u533a\u5206\u5927\u5c0f\u5199\u90a3\u4e48\u5927\u5199\u7684\u4f1a\u6392\u5728\u524d\u9762<br \/>\n(&#8220;File2.txt&#8221;,&#8221;file1&#8243;,&#8221;file11.txt&#8221;,&#8221;file22.txt&#8221;)<\/p>\n<p>\u7528\u6237\u81ea\u5b9a\u4e49\u6392\u5e8f<br \/>\nusort() uasort() uksort()<\/p>\n<p>\u4f8b\u5982usort() \/\/\u5c0f\u5230\u5927\u6392\u5e8f \u7d22\u5f15\u4f1a\u91cd\u65b0\u8d4b\u503c0 \u5f00\u59cb<\/p>\n<p>$arr = array(&#8220;Peter&#8221;, &#8220;glenn&#8221;,&#8221;Cleveland&#8221;,&#8221;peter&#8221;,&#8221;cleveland&#8221;, &#8220;Glenn&#8221;);<br \/>\nusort($arr, &#8220;my_sort&#8221;);<\/p>\n<p>function my_sort($a, $b)<br \/>\n{<br \/>\nif ($a == $b) return 0; \/\/0 \u6392\u5e8f\u4e0d\u53d8<br \/>\nreturn ($a &gt; $b) ? -1 : 1; \/\/a&gt;b,a\u8d4b\u503c1\u5411\u540e\u9000 \u5426\u5219\u8d4b\u503c-1\u524d\u8fdb<br \/>\n}<br \/>\nprint_r ($arr);<\/p>\n<p>uasort() \/\/ \u8ddfusort\u529f\u80fd\u4e00\u6837\u4f46\u662f\u7d22\u5f15\u503c\u4e0d\u53d8<\/p>\n<p>uksort() \/\/ \u5927\u5230\u5c0f\u6392\u5e8f \u4f46\u662f\u7d22\u5f15\u503c\u4e0d\u53d8<\/p>\n<p>\u6570\u7ec4\u62c6\u5206 \u5408\u5e76<br \/>\n$a=array(0=&gt;&#8221;Dog&#8221;,1=&gt;&#8221;Cat&#8221;,2=&gt;&#8221;Horse&#8221;,3=&gt;&#8221;Bird&#8221;);<br \/>\narray_slice() \/\/\u8fc7\u6ee4\u6570\u7ec4\uff0c\u9009\u6307\u5b9a\u6570\u7ec4\u4e2d\u7684\u5143\u7d20<br \/>\nprint_r(array_slice($a,1,2)); \/\/[0] =&gt; Cat [1] =&gt; Horse<br \/>\nprint_r(array_slice($a,-2,1)); \/\/[0] =&gt; Horse<\/p>\n<p>array_splice() \/\/\u8fc7\u6ee4\u6570\u7ec4\uff0c\u8ddf\u4e0a\u9762\u5dee\u4e0d\u591a<\/p>\n<p>array_combine($a1,$a2); \/\/\u5408\u5e76\u6570\u7ec4\uff0c $a1\u6570\u7ec4\u662f\u7d22\u5f15\uff0c$a2\u6570\u7ec4\u4e3a\u503c\uff0c\u4e24\u6570\u7ec4\u5408\u5e76\u6210\u4e00\u4e2a\u6570\u7ec4<\/p>\n<p>array_merge($a,$b,$c,&#8230;.); \/\/\u5408\u5e76\u6570\u7ec4\uff0c\u524d\u9762\u7684\u6570\u7ec4\u5982\u4f55\u540e\u9762\u7684\u6570\u7ec4\u7d22\u5f15\u91cd\u590d\uff0c\u5c31\u4f1a\u88ab\u540e\u9762\u7684\u8986\u76d6\u3002<br \/>\narray_merge($a) \/\/\u8f93\u5165\u5355\u4e2a\u6570\u7ec4\uff0c\u7d22\u5f15\u4ece\u9ed8\u8ba4\u4ece0\u5f00\u59cb\u3002<br \/>\n\u53c2\u8003http:\/\/www.w3school.com.cn\/php\/func_array_merge.asp<\/p>\n<p>array_intersect($a1,$a2); \/\/\u9009\u51fa\u6570\u7ec4\u516c\u5171\u7684\u90e8\u5206\uff0c\u9009\u51fa\u7684\u6570\u7ec4\u7d22\u5f15\u4ee5$a1\u7684\u4e3a\u51c6<\/p>\n<p>array_diff($a1,$a2);\/\/\u9009\u51fa\u4e0d\u540c\u7684\u90e8\u5206\u6392\u5217\u4e3a\u6570\u7ec4\uff0c\u9009\u51fa\u7684\u6570\u7ec4\u7d22\u5f15\u4ee5$a1\u7684\u4e3a\u51c6<\/p>\n<p>\u6808\uff08\u6700\u540e\u8fdb\u7684\u6700\u5148\u51fa\uff0c\u5c31\u50cf\u4e0a\u5b50\u5f39\u4e00\u6837\uff09<\/p>\n<p>\u4f8b\u5982\u5728\u6570\u7ec4\u4e2d\u5165\u6808\uff08\u5411\u6570\u7ec4\u6dfb\u52a0\u5143\u7d20\uff09<br \/>\n$a1=array(&#8216;php&#8217;,&#8217;word&#8217;);<br \/>\n$a1[]=&#8217;one&#8217;; \/\/\u6570\u7ec4\u672b\u5c3e\u589e\u52a0\u5143\u7d20\uff0c\u5165\u6808\u63a8\u8350\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5<br \/>\n$a1[]=&#8217;two&#8217;;<\/p>\n<p>array_push($a1,&#8217;one&#8217;\uff0c&#8217;two&#8217;); \/\/\u6570\u7ec4\u672b\u5c3e\u589e\u52a0\u5143\u7d20,\u6539\u53d8\u539f\u6570\u7ec4\u3002<\/p>\n<p>array_pop($a1);\/\/\u51fa\u6808\u9ed8\u8ba4\u5220\u9664\u6700\u540e\u4e00\u4e2a\uff0c\u6700\u540e\u8fdb\u7684\u6700\u5148\u51fa<\/p>\n<p>\u5806\uff08\u5148\u8fdb\u5148\u51fa\uff0c\u5c31\u50cf\u5438\u7ba1\u4e00\u6837\uff09<\/p>\n<p>array_unshift($a1,&#8217;one&#8217;,&#8217;two&#8217;); \/\/\u6570\u7ec4\u6700\u524d\u9762\u6dfb\u52a0\u5143\u7d20,\u6539\u53d8\u539f\u6570\u7ec4\u3002<\/p>\n<p>array_shift($a1,&#8217;one&#8217;,&#8217;two&#8217;); \/\/\u5220\u9664\u6570\u7ec4\u6700\u524d\u9762\u5143\u7d20\u3002<\/p>\n<p>unset() \/\/\u53ef\u4ee5\u5220\u9664\u53d8\u91cf\uff0c\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff0c\u5bf9\u8c61\u4e2d\u7684\u6210\u5458\u3002<br \/>\nunset($a1[5]);<\/p>\n<p>\u5176\u4ed6\u64cd\u4f5c\u6570\u7ec4\u51fd\u6570<\/p>\n<p>array_rand($a1,1); \/\/\u968f\u673a\u53d61\u4e2a\u6570\u7ec4\u7684\u7d22\u5f15<\/p>\n<p>\u5982\u679c\u968f\u673a\u83b7\u53d62\u4e2a\u8981\u600e\u4e48\u5199\uff1a<\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/array_rand.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:262px\"><div style=\"padding-top:52.290076335878%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"262\" height=\"137\" class=\"alignnone size-full wp-image-3589 lazyload\" title=\"array_rand\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/array_rand.jpg\" alt=\"array_rand\"><\/figure><\/a>\n<p>shuffle($a1); \/\/\u968f\u673a\u6392\u5217\u6570\u7ec4\u3002<\/p>\n<p>array_sum($a1); \/\/\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u6c42\u548c<\/p>\n<p>range()\/\/\u521b\u5efa\u7b80\u5355\u6709\u89c4\u5f8b\u7684\u6570\u7ec4\u3002<br \/>\nrange(&#8216;a&#8217;,&#8217;k&#8217;) \/\/\u7d22\u5f15\u662f0\uff0c\u521b\u5efaa\u5230k\u7684\u6570\u7ec4<br \/>\nrange(0,50,10) \/\/\u7d22\u5f15\u662f0\uff0c\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u503c\u662f0\u523050\u5e76\u4e14\u6570\u503c\u5dee\u4e3a10<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u6587\u4ef6\u5305\u542b<\/span><\/p>\n<p>require(&#8216;demo.php&#8217;) \u00a0\/\/\u5f15\u5165\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u4ee5\u4e0b\u7684\u4ee3\u7801\u4e0d\u4f1a\u6267\u884c\u3002<\/p>\n<p>include() \u00a0\/\/ \u00a0\u5f15\u5165\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u4ee5\u4e0b\u7684\u4ee3\u7801\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n<p>require\u4e00\u4e2a\u6587\u4ef6\u5b58\u5728\u9519\u8bef\u7684\u8bdd\uff0c\u90a3\u4e48\u7a0b\u5e8f\u5c31\u4f1a\u4e2d\u65ad\u6267\u884c\u4e86\uff0c\u5e76\u663e\u793a\u81f4\u547d\u9519\u8bef<br \/>\ninclude\u4e00\u4e2a\u6587\u4ef6\u5b58\u5728\u9519\u8bef\u7684\u8bdd\uff0c\u90a3\u4e48\u7a0b\u5e8f\u4e0d\u4f1a\u4e2d\u7aef\uff0c\u800c\u662f\u7ee7\u7eed\u6267\u884c\uff0c\u5e76\u663e\u793a\u4e00\u4e2a\u8b66\u544a\u9519\u8bef\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">\u5b57\u7b26\u4e32\u64cd\u4f5c\u5904\u7406<\/span><\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u5904\u7406\u5b57\u7b26\u4e32\uff0c\u662f\u56e0\u4e3a\u5b57\u7b26\u4e32\u662f\u8981\u5199\u5165\u6570\u636e\u5e93\u4e3a\u4e86\u51cf\u5c11\u5197\u4f59\u548c\u63d0\u4f9b\u5b89\u5168\u5fc5\u987b\u8981\u5bf9\u5b57\u7b26\u4e32\u5904\u7406\u4e4b\u540e\u624d\u4f20\u5165\u5230\u6570\u636e\u5e93\uff0c\u9632\u6b62\u6076\u610f\u6ce8\u5165\u3002<\/p>\n<p>trim() \u00a0\/\/\u6e05\u9664\u5b57\u7b26\u4e32\u6700\u4e24\u8fb9\u7684\u7a7a\u683c\u3002<\/p>\n<p>ltrim() \u00a0\/\/\u6e05\u9664\u6700\u5de6\u8fb9<\/p>\n<p>rtrim() \u00a0\/\/\u6e05\u9664\u6700\u53f3\u8fb9<\/p>\n<p>nl2br() \u00a0\/\/\u6548\u679c\u662f\u5c06\u7528\u6237\u7684\u56de\u8f66\u952e\u548c\\n\u5728html\u4e0a\u89e3\u6790\u6210&lt;br&gt;,\u4f8b\u5982\u53d1\u8d34\u9700\u8981\u56de\u8f66\u6362\u884c\u3002<\/p>\n<p>htmlspecialchars() \u00a0\/\/\u5c06\u7279\u6b8a\u5b57\u7b26\u8f6c\u4e49\uff0c\u4e3b\u8981\u9632\u6b62XSS<\/p>\n<p>strip_tags() \u00a0\/\/\u5220\u9664\u5b57\u7b26\u4e32\u91cc\u6240\u6709\u7684html\u6807\u7b7e<\/p>\n<p>addslashes() \u00a0\/\/\u5c06\u7279\u6b8a\u591a\u52a0\u4e00\u4e2a\\\u8f6c\u4e49\uff08\u5728\u4f20\u5165\u5230\u6570\u636e\u5e93\u4e2d\uff09<\/p>\n<p>stripcslashes() \u00a0\/\/\u591a\u51fa\u6765\u7684\/\u5220\u9664\u6389 \u00a0\uff08\u5728\u663e\u793a\u5230\u9875\u9762\u4e2d\uff09<\/p>\n<p>explode(&#8216;@&#8217;,&#8217;chen@163.com&#8217;) \u00a0\/\/\u6309@\u62c6\u5206\u6210\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n<p>implode(&#8216;@&#8217;,\u6570\u7ec4) \u00a0\/\/\u5c06\u4e00\u4e2a\u6570\u7ec4\u91cc\u7684\u5143\u7d20\u7528@\u5408\u5e76\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002<\/p>\n<p>strtok() \u00a0\/\/\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u4ee5\u591a\u4e2a\u5206\u5272\u70b9\u4e3a\u51c6\u8fdb\u884c\u5206\u5272\uff0c\u4f8b\u5982\uff1a<\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php_strtok.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:239px\"><div style=\"padding-top:92.050209205021%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"239\" height=\"220\" class=\"alignnone size-full wp-image-3598 lazyload\" title=\"php_strtok\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php_strtok.jpg\" alt=\"php_strtok\"><\/figure><\/a>\n<p>&nbsp;<\/p>\n<p>substr(&#8216;\u5b57\u7b26\u4e32&#8217;,0,2) \u00a0 \/\/ \u4ece\u7b2c0\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u53d62\u4e2a\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u5b57\u7b26\u4e32<\/p>\n<p>str_split(&#8216;\u5b57\u7b26\u4e32&#8217;) \u00a0 \/\/\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u5355\u4e2a\u4e2a\u4f53\uff0c\u8fd4\u56de\u6570\u7ec4<\/p>\n<p>strrev(&#8216;\u5b57\u7b26\u4e32&#8217;) \u00a0 \/\/ \u5c06\u5b57\u7b26\u4e32\u987a\u5e8f\u5012\u8fc7\u6765<\/p>\n<p>\u5b57\u7b26\u4e32\u6bd4\u8f83<\/p>\n<p>strcmp(&#8216;c&#8217;,&#8217;b&#8217;) \u00a0\/\/c&gt;b\u00a0\u8fd4\u56de1 \u00a0&lt; \u8fd4\u56de-1 \u00a0=\u8fd4\u56de0\uff0c\u533a\u5206\u5927\u5c0f<\/p>\n<p>strcasecmp() \u00a0\/\/\u4e0d\u533a\u5206\u5927\u5c0f<\/p>\n<p>strnatcmp(&#8216;2&#8242;,&#8217;10&#8217;) \u00a0\/\/\u6309\u81ea\u7136\u6392\u5e8f\uff0c\u628a10\u770b\u6210\u4e00\u4e2a\u6570\u5b57<\/p>\n<p>strcmp(&#8216;2&#8242;,&#8217;10&#8217;) \u00a0\/\/\u6309\u975e\u81ea\u7136\u6392\u5e8f\uff0c10\u770b\u6210\u4e861<\/p>\n<p>substr_count(&#8216;abcde&#8217;,&#8217;a&#8217;) \u00a0\/\/a \u5728\u5b57\u7b26\u4e32\u51fa\u73b0\u7684\u6b21\u6570<\/p>\n<p>strlen(&#8216;abc&#8217;) \u00a0\/\/3 \u00a0\u5b57\u7b26\u4e32\u957f\u5ea6<\/p>\n<p>strstr(&#8216;abce&#8217;,&#8217;b&#8217;) \u00a0 \/\/ \u5f97\u5230 bce \u00a0\uff0c\u533a\u5206\u5927\u5c0f\u5199<\/p>\n<p>stristr(&#8216;abce&#8217;,&#8217;B&#8217;) \u00a0 \/\/ \u5f97\u5230 bce \u00a0\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/p>\n<p>strpos(&#8216;abceb&#8217;,\u2018b\u2019) \u00a0\/\/\u8fd4\u56de1\u7d22\u5f150\u5f00\u59cb\uff0c\u67e5\u627e\u67d0\u5b57\u7b26\u4e32\u6700\u5148\u51fa\u73b0\u5728\u4e00\u6bb5\u5b57\u7b26\u4e32\u7684\u4ec0\u4e48\u4f4d\u7f6e<\/p>\n<p>strrpos(&#8216;abceb&#8217;,\u2018b\u2019) \u00a0\/\/\u5012\u5e8f\uff0c\u6700\u540e\u51fa\u73b0\u7684\u4f4d\u7f6e<\/p>\n<p>str_replace(&#8216;Lee&#8217;,&#8217;Wq&#8217;,&#8217;This is Lee!&#8217;) \u00a0\/\/This is Wq \u5b57\u7b26\u4e32\u66ff\u6362<\/p>\n<p>substr_replace(&#8216;abce&#8217;,&#8217;$$$&#8217;,0,2) \/\/ $$$ce \u00a0 \u4ece\u7b2c0\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u66ff\u63622\u4e2a<\/p>\n<p>*\u6ce8\u610f\u4ee5\u4e0a\u7684\u65b9\u6cd5\u9002\u7528\u4e8e\u82f1\u6587\u5b57\u7b26\u4e32\u5904\u7406\u5bf9\u4e8e\u4e2d\u6587\u5b57\u7b26\u4e32\u5904\u7406\u8fd8\u9700\u8981\u767e\u5ea6\u4e0b<\/p>\n<p><span style=\"color: #ff0000;\">\u65f6\u95f4\u6233<\/span><\/p>\n<p><a href=\"https:\/\/sdeno.com\/?p=4413\" target=\"_blank\">\u8be6\u7ec6\u8bbe\u7f6e\u65b9\u6cd5\u70b9\u8fd9\u91cc<\/a><\/p>\n<p>date_default_timezone_set(&#8216;Asia\/Shanghai&#8217;) \u00a0\/\/\u5148\u8bbe\u7f6e\u670d\u52a1\u5668\u65f6\u533a<\/p>\n<p>checkdate(7,16,2015) \u00a0\/\/\u6708\u65e5\u5e74 \u00a0\u68c0\u67e5\u65f6\u95f4\u662f\u5426\u6709\u8bef<\/p>\n<p>date(&#8216;Y-m-d H:i:s&#8217;) \u00a0\/\/ 2015-11-11<\/p>\n<p>time() \u00a0\/\/\u76f4\u63a5\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u6233<\/p>\n<p>date(&#8216;Y-m-d H:i:s&#8217;,\u65f6\u95f4\u6233) \u00a0\/\/\u7b2c\u4e8c\u4e2a\u53c2\u6570\u52a0\u5165\u65f6\u95f4\u6233\u53ef\u4ee5\u8f6c\u5316\u6210 \u6b63\u5e38\u65f6\u95f4\u683c\u5f0f<\/p>\n<p>gettimeofday() \u00a0\/\/\u8fd4\u56de\u6570\u7ec4\uff0c\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u4fe1\u606f\u3002<\/p>\n<p>getdate() \/\/\u8fd4\u56de\u6570\u7ec4\uff0c\u83b7\u53d6\u8be6\u7ec6\u7684\u5f53\u524d\u65f6\u95f4\u4fe1\u606f\u3002<\/p>\n<p>mktime(\u65f6,\u5206,\u79d2,\u6708,\u65e5,\u5e74) \u00a0 \/\/\u83b7\u53d6\u6307\u5b9a\u65f6\u95f4\u6233<\/p>\n<p>strtotime(&#8216;2011-11-11 20:20:20&#8217;) \u00a0\/\/\u5c06\u6307\u5b9a\u65f6\u95f4\u8f6c\u6210\u65f6\u95f4\u6233<\/p>\n<p>microtime() \u00a0\/\/\u8fd4\u56de \u5f53\u524d\u5fae\u5999\u6570\u548c\u65f6\u95f4\u6233 \u00a0\uff08\u5fae\u5999\u6570+\u65f6\u95f4\u6233\u5c31\u662f\u5f53\u524d\u6700\u7cbe\u786e\u65f6\u95f4\uff09<\/p>\n<p><span style=\"color: #ff0000;\">Cookie \u4e0e Session\u533a\u522b<\/span><\/p>\n<p>cookie\u548csession\u90fd\u53ef\u4ee5\u8de8\u9875\u9762\u83b7\u53d6\u5230\u53e6\u4e00\u4e2a\u9875\u9762\u8bbe\u7f6e\u7684\u503c<\/p>\n<p>cookie\u7528\u9014\uff1a\u5b58\u50a8\u5728\u5ba2\u6237\u7aef\u4e2d\uff0c\u8bb0\u5f55\u4f1a\u5458\u767b\u5f55\u4fe1\u606f\uff0c\u8d2d\u7269\u8f66\u3002\u3002\u56e0\u4e3a\u5b83\u4e0d\u5360\u7528\u8d44\u6e90\u670d\u52a1\u5668\uff0c\u5173\u6d4f\u89c8\u5668\u81ea\u52a8\u5220\u9664\u3002<\/p>\n<p>session\u7528\u9014\uff1a\u5b58\u50a8\u5728\u670d\u52a1\u5668\u7aef\uff0c\u670d\u52a1\u5668\u624d\u80fd\u83b7\u53d6\u5ba2\u6237\u7aef\u4e0d\u80fd\uff0c\u7528\u5728\u540e\u53f0\u7ba1\u7406\u767b\u5f55\u4eba\u5c11\u7684\uff0c\u5b89\u5168\u4e00\u6bb5\u65f6\u95f4\u4e0d\u64cd\u4f5c\u5c31\u81ea\u52a8\u8fc7\u671f\u9ed8\u8ba41440\u79d2\u540e\u81ea\u52a8\u5220\u9664\uff0c\u5173\u6d4f\u89c8\u5668\u4e5f\u81ea\u52a8\u5220\u9664\u3002<\/p>\n<p>setcookie(&#8216;name&#8217;,&#8217;lee&#8217;,time()+(7*24*60*60)) \u00a0\/\/\u521b\u5efa\u4e00\u4e2acookie\u5c5e\u6027\u4e3aname\u503c\u4e3alee\uff0c\u4e14\u57287\u5929\u540e\u8fc7\u671f<\/p>\n<p>$_COOKIE[&#8216;name&#8217;] \u00a0\/\/\u83b7\u53d6name\u7684\u503c \u00a0\uff08\u61622\uff0c3\u79d2\u624d\u80fd\u83b7\u53d6\u5230\uff09<\/p>\n<p>setcookie(&#8216;name&#8217;,&#8217;lee&#8217;,time()-1) \u00a0\/\/\u5220\u9664\u4e00\u4e2acookie \u8ba9\u65f6\u95f4\u8fc7\u53bb1\u79d2<\/p>\n<p>\u4f7f\u7528session\u524d \u5fc5\u987b\u4e4b\u524d\u5f00\u59cb\u529f\u80fd session_start()<\/p>\n<p>$_SESSION[&#8216;name&#8217;]=&#8217;lee&#8217;; \u00a0\/\/\u521b\u5efa\u4e00\u4e2asession<\/p>\n<p>$_SESSION[&#8216;name&#8217;] \u00a0\/\/\u83b7\u53d6<\/p>\n<p>unset($_SESSION[&#8216;name&#8217;]) \u00a0\/\/\u5220\u9664\u6307\u5b9asession<\/p>\n<p>session_destroy() \u00a0\/\/\u5220\u9664\u6240\u6709session (\u5220\u9664\u61622\uff0c3\u79d2)<\/p>\n<p><span style=\"color: #ff0000;\">\u4e0a\u4f20\u6587\u4ef6\u76f8\u5173\u51fd\u6570<\/span><\/p>\n<p>\u6848\u4f8b<a href=\"https:\/\/sdeno.com\/zp\/imgup\/img.php\" target=\"_blank\">https:\/\/sdeno.com\/zp\/imgup\/img.php<\/a><\/p>\n<p>PHP\u4e0a\u4f20\u914d\u7f6e\u662f\u5728php.ini\u8fd9\u91cc\u8bbe\u7f6e\u7684\uff0c\u91cd\u8981\u53c2\u6570\u662f\uff1a<\/p>\n<p>file_uploads \u00a0\/\/\u670d\u52a1\u5668\u662f\u5426\u5f00\u542f\u4e0a\u4f20<\/p>\n<p>upload_max_filesize \u00a0\/\/\u8bbe\u7f6e\u6587\u4ef6\u4e0a\u4f20\u6700\u5927MB<\/p>\n<p>&lt;form enctype=&#8221;multipart\/form-data&#8221;&gt; \u00a0\/\/\u6b64\u5c5e\u6027\u5fc5\u586b\u5426\u5219\u4e0d\u80fd\u4e0a\u4f20<\/p>\n<p>&lt;input type=&#8221;hidden&#8221; name=&#8221;MAX_FILE_SIZE&#8221; value=&#8221;1000000&#8243;&gt; \/\/\u63a8\u8350\u8bbe\u7f6e\u4e00\u4e2a\u9690\u85cf\u57df\u8fd9\u91cc\u53ef\u4ee5\u5feb\u901f\u5224\u65ad\u4e0a\u4f20\u7684\u6587\u4ef6\u5927\u5c0f\u662f\u5426\u64cd\u4f5c\u4e86\u670d\u52a1\u5668\u5141\u8bb8\u7684\u5927\u5c0f\u514d\u53bb\u4e86\u7528\u6237\u4e0a\u4f20\u540e\u624d\u53d1\u73b0\u81ea\u5df1\u4e0a\u4f20\u7684\u6587\u4ef6\u8d85\u8fc7\u4e86\u670d\u52a1\u5141\u8bb8\u7684\u5927\u5c0f\u7b49\u5f85\u7684\u65f6\u95f4\u3002<\/p>\n<p>$_FILES \u00a0\/\/\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\uff0c\u53ef\u4ee5\u83b7\u53d6\u5230\u4e0a\u4f20\u6587\u4ef6\u7684\u4fe1\u606f\uff0c\u4f8b\u5982<\/p>\n<p>name \u00a0 \/\/\u6587\u4ef6\u540d \u00a0 123.jpg<\/p>\n<p>type \u00a0 \/\/\u6587\u4ef6\u7c7b\u578b \u00a0image\/jpg \u00a0\u4e0d\u540c\u6d4f\u89c8\u5668\u663e\u793a\u7c7b\u578b\u4e0d\u4e00\u6837\u8981\u6ce8\u610f\u517c\u5bb9<\/p>\n<p>tmp_name \u00a0\/\/\u83b7\u53d6\u4e34\u65f6\u6587\u4ef6 \u7528\u4e8e\u5224\u65ad\u4e0a\u4f20\u7684\u6587\u4ef6\u662f\u5426\u6210\u529f<\/p>\n<p>error \u00a0\/\/\u8fd4\u56de\u6570\u5b57\uff0c\u4e0a\u4f20\u6210\u529f\u8fd4\u56de0\uff0c\u5176\u4ed6\u4e0d\u540c\u6570\u5b57\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u4e0d\u4e00\u6837<\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/error1.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:678px\"><div style=\"padding-top:15.634218289086%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"678\" height=\"106\" class=\"alignnone size-full wp-image-3606 lazyload\" title=\"error1\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/error1.jpg\" alt=\"error1\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/error1.jpg 678w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/error1-300x46.jpg 300w, https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/error1-624x97.jpg 624w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\"><\/figure><\/a>\n<p>size \u00a0\/\/ \u6587\u4ef6\u5927\u5c0f \u5b57\u8282\u5355\u4f4d<\/p>\n<p>\u5982\u679c\u83b7\u53d6\u6587\u4ef6\u4fe1\u606f\uff1f\u4f8b\u5982<\/p>\n<p>&lt;input type=&#8221;file&#8221; name=&#8221;userfile&#8221; \/&gt;<\/p>\n<p>$_FILES[&#8216;userfile&#8217;][&#8216;tmp_name&#8217;] \u00a0 \/\/\u539f\u7406\u540c\u4e0a<\/p>\n<p>is_uploaded_file() \u00a0 \u00a0\/\/\u5224\u65ad\u6587\u4ef6\u662f\u5426\u4e0a\u4f20\u6210\u529f \uff08\u5fc5\u987b\u7528post\u65b9\u5f0f\u4e0a\u4f20\u6587\u4ef6\uff09<\/p>\n<p>\u4f8b\u5982\uff1ais_uploaded_file($_FILES[&#8216;userfile&#8217;][&#8216;tmp_name&#8217;])<\/p>\n<p>move_uploaded_file(\u4e34\u65f6\u6587\u4ef6\u5730\u5740,\u5b58\u653e\u5730\u5740)<\/p>\n<p>\u4f8b\u5982\uff1amove_uploaded_file($_FILES[&#8216;userfile&#8217;][&#8216;tmp_name&#8217;],\u2018upload\/123.jpg\u2019)<\/p>\n<p>is_dir() \u00a0\/\/\u5224\u65ad\u4e00\u4e2a\u76ee\u5f55\u662f\u5426\u5b58\u5728<\/p>\n<p>mkdir(&#8216;upload&#8217;,0777) \u00a0 \/\/\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">php\u64cd\u4f5c\u6570\u636e\u5e93\uff08\u589e\u3001\u5220\u3001\u6539\u3001\u67e5\uff09<\/span><\/p>\n<p>$conn = mysql_connect(&#8216;localhost&#8217;,&#8217;root&#8217;,&#8217;123&#8242;); \u00a0 \/\/\u8fde\u63a5<\/p>\n<p>mysql_select_db(&#8216;school&#8217;); \u00a0 \u00a0\/\/\u9009\u62e9\u6570\u636e\u5e93<\/p>\n<p>mysql_query(&#8216;SET NAMES UTF8&#8217;); \u00a0 \/\/ \u00a0\u8bbe\u7f6e\u5b57\u7b26\u96c6<\/p>\n<p>$query = &#8220;SELECT * FROM grade&#8221;; \u00a0 \/\/ \u67e5\u8be2grade\u8868\u4e0b\u6240\u6709\u4fe1\u606f<\/p>\n<p>$result = mysql_query($query); \u00a0 \/\/\u6267\u884c\u6210\u529f\uff0c\u8fd4\u56de\u6570\u7ec4<\/p>\n<p>print_r(mysql_fetch_array($result,MYSQL_ASSOC)); \u00a0 \/\/ <span style=\"color: #ff0000;\">\u67e5<\/span>\u770b\u8fd4\u56de\u6570\u7ec4\u4fe1\u606f<\/p>\n<p>mysql_free_result($result); \u00a0\/\/\u91ca\u653e\u8bb0\u5f55\u96c6\u8d44\u6e90<\/p>\n<p>mysql_close(); \u00a0\/\/\u5173\u95ed\u6570\u636e\u5e93<\/p>\n<p>&nbsp;<\/p>\n<p>\u65b0\u589e\u6570\u636e<br \/>\n$query = &#8220;INSERT INTO grade (name,email,point,regdate) VALUES (&#8216;\u80e1\u5fc3\u9e4f&#8217;,&#8217;bigbird@sina.com.cn&#8217;,67,NOW())&#8221;;<br \/>\n@mysql_query($query) or die(&#8216;\u65b0\u589e\u9519\u8bef\uff1a&#8217;.mysql_error());<\/p>\n<p>\u4fee\u6539\u6570\u636e<br \/>\n$query = &#8216;UPDATE grade SET point=87 WHERE id=8&#8217;;<br \/>\n@mysql_query($query) or die(&#8216;\u4fee\u6539\u9519\u8bef\uff1a&#8217;.mysql_error());<\/p>\n<p>\u5220\u9664\u6570\u636e<br \/>\n$query = &#8220;DELETE FROM grade WHERE id=8&#8221;;<br \/>\n@mysql_query($query) or die(&#8216;\u5220\u9664\u9519\u8bef\uff1a&#8217;.mysql_error());<\/p>\n<p>&nbsp;<\/p>\n<p>\u4f8b\u5b50\uff1a\u628a\u67d0\u8868\u7684\u6bcf\u884c\u6570\u636e\u90fd\u904d\u5386\u51fa\u6765<\/p>\n<pre>$query = \"SELECT id,name,email,regdate FROM grade\";\r\n  $result = mysql_query($query) or die('SQL\u8bed\u53e5\u6709\u8bef\uff1a'.mysql_error());\r\n  while (!!$row = mysql_fetch_array($result)) {\r\n  echo $row['id'].'----'.$row['name'].'----'.$row['email'];\r\n  echo '&lt;br \/&gt;';\r\n }<\/pre>\n<p>php\u64cd\u4f5cmysql\u5e38\u7528\u51fd\u6570\uff1a<\/p>\n<p>mysql_fetch_array(); \u00a0 \/\/\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\uff0c\u663e\u793a\u6570\u636e\u5e93\u4fe1\u606f<\/p>\n<p>mysql_field_name($result,3) \u00a0 \/\/\u663e\u793a\u6307\u5b9a \u5b57\u6bb5\u540d\u79f0<\/p>\n<p>mysql_num_rows(); \u00a0\/\/\u6709\u591a\u5c11\u884c\u6570\u636e<\/p>\n<p>mysql_num_fields() \/\/ \u591a\u5c11\u5b57\u6bb5<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5b57\u7b26\u4e32\u622a\u53d6<\/p>\n<p>mb_substr($str,1,20,&#8217;utf-8&#8242;) \u00a0\/\/\u8f7d\u5165\u5b57\u7b26\u4e32\uff0c\u5f00\u59cb\u4f4d\u7f6e\uff0c\u622a\u53d6\u591a\u5c11\u5185\u5bb9\uff0c\u5b57\u7b26\u96c6<\/p>\n<p>\u83b7\u53d6\u5b57\u7b26\u4e32\u957f\u5ea6<\/p>\n<p>mb_strlen($str,&#8217;utf-8&#8242;)<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/sdeno.com\/?p=4081\" target=\"_blank\">php\u9762\u5411\u5bf9\u8c61<\/a><\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2014\/06\/php5.txt\">php5<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>* \u53d8\u91cf\u548c\u5e38\u91cf\u533a\u5206\u5927\u5c0f\u5199 $a =10; $A =20; \u4ee5\u4e0a\u53d8\u91cf\u540d\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684. echo Echo \u4e0d\u533a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,9],"tags":[],"class_list":["post-2985","post","type-post","status-publish","format-standard","hentry","category-php","category-9"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2985"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/2985\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}