{"id":56,"date":"2018-07-31T11:05:08","date_gmt":"2018-07-31T03:05:08","guid":{"rendered":"http:\/\/robot.tanxiaodian.com\/?p=56"},"modified":"2023-07-05T18:57:00","modified_gmt":"2023-07-05T10:57:00","slug":"php%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/log.tanxiaodian.com\/?p=56","title":{"rendered":"PHP\u51fd\u6570"},"content":{"rendered":"\n<p>\/\/\u6570\u7ec4\u7684\u4ea4\u96c6 array_intersect()&nbsp; \u503c\u7684\u4ea4\u96c6&nbsp; &nbsp; &nbsp; &nbsp;<\/p>\n\n\n\n<p>\/\/\u6570\u7ec4\u7684\u5dee\u96c6 array_diff()&nbsp; \u503c\u7684\u5dee\u96c6&nbsp; &nbsp;<\/p>\n\n\n\n<p>\/\/\u6570\u7ec4\u7684\u4ea4\u96c6 array_intersect_key()&nbsp; \u952e\u7684\u4ea4\u96c6&nbsp; &nbsp; &nbsp; &nbsp;<\/p>\n\n\n\n<p>\/\/\u6570\u7ec4\u7684\u5dee\u96c6 array_diff_key()&nbsp; \u952e\u7684\u5dee\u96c6&nbsp; &nbsp;<\/p>\n\n\n\n<p>\/\/array_intersect_assoc()&nbsp; \u952e\u503c\u5bf9\u7684\u4ea4\u96c6<\/p>\n\n\n\n<p>\/\/array_diff_assoc() \u952e\u503c\u5bf9\u7684\u5dee\u96c6(\u952e\u548c\u503c\u90fd\u8981\u6bd4\u8f83)<\/p>\n\n\n\n<p>\/\/\u4e24\u4e2a\u6570\u7ec4\u7ec4\u6210\u952e\u503c\u5bf9\u6570\u7ec4&nbsp; &nbsp; array_combine($arr_key,$arr_val);<\/p>\n\n\n\n<p>\/\/\u8ba1\u7b97\u6570\u7ec4\u4e2d\u503c\u51fa\u73b0\u7684\u6b21\u6570\u8fd4\u56de\u5404\u503c\u51fa\u73b0\u6b21\u6570\u6570\u7ec4 array_value_count($arr);\u5982[1,2,3,3,4] \u8fd4\u56de [1,1,2,1]<\/p>\n\n\n\n<p>\/\/\u6570\u7ec4\u952e\u503c\u5bf9 \u4ea4\u6362 array_flip<\/p>\n\n\n\n<p>\/\/array_column \u51fd\u6570\u57285.4\u662f\u6ca1\u6709\u7684\u9700\u8981\u5199\u517c\u5bb9<\/p>\n\n\n\n<p>\/\/\u5220\u9664\u6570\u7ec4\u6700\u540e\u4e00\u4e2a\u5143\u7d20 array_pop($arr)<\/p>\n\n\n\n<p>\/\/\u5f53\u524d\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84&nbsp; &nbsp; &nbsp;dirname(__FILE__)<\/p>\n\n\n\n<p>\/\/\u89e3\u6790\u6587\u4ef6\u8def\u5f84&nbsp; pathinfo($path,$option = null)&nbsp; \u8fd4\u56de\u6570\u7ec4\u5305\u542b\u952e[&#8216;dirname&#8217;,&#8217;basename&#8217;,&#8217;extension&#8217;,&#8217;filename&#8217;]&nbsp; \u5206\u522b\u662f\u8def\u5f84\u540d \u3001\u6587\u4ef6\u5168\u540d\u3001\u6587\u4ef6\u6269\u5c55\u540d\u3001\u6587\u4ef6\u540d<\/p>\n\n\n\n<p>\/\/\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728&nbsp; file_exists($filepath)&nbsp; \u5b58\u5728\u8fd4\u56detrue \u4e0d\u5b58\u5728\u8fd4\u56defalse<\/p>\n\n\n\n<p>\/\/\u8c03\u7528\u67d0\u7c7b\u7684\u67d0\u65b9\u6cd5&nbsp; &nbsp;call_user_func(array($object,$functionname))<\/p>\n\n\n\n<p>\/\/\u5b57\u7b26\u4e32\u53cd\u8f6c&nbsp;&nbsp;strrev()<\/p>\n\n\n\n<p>\/\/\u5b57\u7b26\u4e32\u8865\u5168&nbsp;&nbsp;str_pda(&#8216;\u88ab\u8865\u5145\u7684\u5b57\u7b26\u4e32\u2019,&#8217;\u8865\u5145\u5b8c\u540e\u5b57\u7b26\u4e32\u7684\u957f\u5ea6&#8217;,&#8217;\u7528\u4ec0\u4e48\u5b57\u7b26\u8865\u5145&#8217;,&#8217;STR_PAD&#8230;&#8217;);STR_PAD_LEFT:\u5728\u5de6\u8fb9STR_PAD_RIGHT:\u5728\u53f3\u8fb9STR_PAD_BOTH:\u4e24\u8fb9\u8865<\/p>\n\n\n\n<p>\/\/php \u6570\u7ec4\u5185\u6240\u6709\u5143\u7d20\u7ecf\u5386\u51fd\u6570\u8fdb\u884c\u5904\u7406&nbsp;array_map<\/p>\n\n\n\n<p>$func&nbsp;=&nbsp;function($value)&nbsp;{<br>return&nbsp;$value&nbsp;*&nbsp;2;<br>};<br>array_map($func,&nbsp;range(1,&nbsp;5));<\/p>\n\n\n\n<p>array_map\u793a\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$province_name=\"\u5e7f\u897f\u58ee\u65cf\u81ea\u6cbb\u533a\";\n$arrNation = ['\u58ee\u65cf', '\u7ef4\u543e\u5c14' ,'\u56de\u65cf' ,'\u7701', '\u81ea\u6cbb\u533a', '\u5e02'];\narray_map(function($word) use (&amp;$province_name){ ;\n    $province_name = str_replace($word, '', $province_name);\n}, $arrNation);<\/pre>\n\n\n\n<p>\/\/php&nbsp; \u51fd\u6570str_split($str_src,$elemnum); \u62c6\u5206\u5b57\u7b26\u4e32\u4e3a\u6570\u7ec4 $elemnum\u4e3a\u6b65\u957f<\/p>\n\n\n\n<p>\/\/php \u51fd\u6570&nbsp;stripslashes($str)&nbsp; \u53bb\u6389\u53cd\u659c\u6760\\&nbsp; \u5982\u679c\u6709\u4e24\u4e2a\u53cd\u659c\u6760\\\\\u5219\u53d8\u4e3a\u4e00\u4e2a\\<\/p>\n\n\n\n<p>\/\/\u952e\u503c\u5bf9\u6570\u7ec4\u6392\u5e8f&nbsp; &nbsp;array_multisort(array_column($arr,&#8217;price&#8217;),SORT_DESC,$arr);<\/p>\n\n\n\n<p>\/\/\u51fd\u6570\u5728\u6307\u5b9a\u7684\u9884\u5b9a\u4e49\u5b57\u7b26\u524d\u6dfb\u52a0\u53cd\u659c\u6760\u3002&nbsp; addslashes<\/p>\n\n\n\nlist($width, $height, $type, $attr) = getimagesize($fileName);\/\/\u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n\n\n\n<p><strong>array_merge<\/strong>  \/\/\u5408\u5e76\u6570\u7ec4<\/p>\n\n\n\n<p>stripslashes  \/\/\u53bb\u9664\u53cd\u659c\u6760<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chdir('..\/');   \u6539\u53d8\u5f53\u524d\u76ee\u5f55<\/pre>\n\n\n\n<p>disk_free_space($ptah)  \u83b7\u53d6\u76ee\u5f55\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4<\/p>\n\n\n\n<p>$tmp = gd_info()   \u83b7\u53d6GD\u5e93\u4fe1\u606f\u7684\u6570\u7ec4 :\u5982 $tmp[&#8216;GD Version&#8217;]  <\/p>\n\n\n\n<p>ini_get(&#8216;upload_max_filesize&#8217;)   \u83b7\u53d6phpini\u914d\u7f6e\u6587\u4ef6\u4fe1\u606f, \u6b64\u5904\u4e3a\u83b7\u53d6\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u9650\u5236<\/p>\n\n\n\n<p>constant(&#8216;PHP_OS&#8217;)  \u8fd4\u56dePHP\u7684\u5e38\u91cf\u503c,\u6b64\u5904\u4e3a\u5f53\u524d\u64cd\u4f5c\u7cfb\u7edf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$opcache_data=opcache_get_configuration()  \u83b7\u53d6opcache\u914d\u7f6e    \u5982$opcache_data['directives']['opcache.enable']\u5224\u65ad\u662f\u5426\u5f00\u542f\u4e86opcache\u670d\u52a1<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">echo $real_path = realpath(\"C:\/PhpProject\/index.php\");\n\u8f93\u51fa: C:\\PhpProject\\index.php\nrealpath()\u51fd\u6570\u8fd4\u56de\u89c4\u8303\u5316\u7684\u7edd\u5bf9\u8def\u5f84\u540d\u3002\u6b64\u51fd\u6570\u53ef\u4ee5\u5220\u9664\u6240\u6709\u7b26\u53f7\u94fe\u63a5\uff08\u4f8b\u5982\u201c \/.\/\u201d\u3001\u201c\/..\/\u201d\u548c\u591a\u4f59\u7684\u201c \/\u201d\uff09\u5e76\u8fd4\u56de\u7edd\u5bf9\u8def\u5f84\u540d\u3002\u8be5\u51fd\u6570\u5728\u5931\u8d25\u65f6\u8fd4\u56defalse\u3002\n<\/pre>\n\n\n\n<p>round($num)  \/\/\u56db\u820d\u4e94\u5165<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\u6570\u7ec4\u7684\u4ea4\u96c6 array_intersect()&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/log.tanxiaodian.com\/?p=56\">Continue reading<span class=\"screen-reader-text\">PHP\u51fd\u6570<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":26,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":1177,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/1177"}],"wp:attachment":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}