{"id":373,"date":"2005-10-30T22:35:50","date_gmt":"2005-10-30T10:35:50","guid":{"rendered":""},"modified":"2005-10-30T22:35:50","modified_gmt":"2005-10-30T10:35:50","slug":"","status":"publish","type":"post","link":"https:\/\/www.mudone.com\/?p=373","title":{"rendered":"PHP\u521d\u5b66\u8005\u5934\u75bc\u95ee\u9898\u603b\u7ed3"},"content":{"rendered":"<p>\u4f5c\u8005\uff1awzpwhw \u4e2d\u6587PHP\u8bba\u575b <\/p>\n<p>\u30101\u3011\u9875\u9762\u4e4b\u95f4\u65e0\u6cd5\u4f20\u9012\u53d8\u91cf get,post,session\u5728\u6700\u65b0\u7684php\u7248\u672c\u4e2d\u81ea\u52a8\u5168\u5c40\u53d8\u91cf\u662f\u5173\u95ed\u7684\uff0c\u6240\u4ee5\u8981\u4ece\u4e0a\u4e00\u9875\u9762\u53d6\u5f97\u63d0\u4ea4\u8fc7\u6765\u5f97\u53d8\u91cf\u8981\u4f7f\u7528$_GET[&#39;foo&#39;],$_POST[&#39;foo&#39;],$_SESSION[&#39;foo&#39;]\u6765\u5f97\u5230<br \/>\n\u5f53\u7136\u4e5f\u53ef\u4ee5\u4fee\u6539\u81ea\u52a8\u5168\u5c40\u53d8\u91cf\u4e3a\u5f00(php.ini\u6539\u4e3aregister_globals = On)\uff1b\u8003\u8651\u5230\u517c\u5bb9\u6027\uff0c\u8fd8\u662f\u5f3a\u8feb\u81ea\u5df1\u719f\u6089\u65b0\u7684\u5199\u6cd5\u6bd4\u8f83\u597d\u3002 <\/p>\n<p>\u30102\u3011Win32\u4e0bapache2 \u7528get\u65b9\u6cd5\u4f20\u9012\u4e2d\u6587\u53c2\u6570\u4f1a\u51fa\u9519<br \/>\ntest.php?a=\u4f60\u597d&amp;b=\u4f60\u4e5f\u597d<br \/>\n\u4f20\u9012\u53c2\u6570\u662f\u4f1a\u5bfc\u81f4\u4e00\u4e2a\u5185\u90e8\u9519\u8bef<br \/>\n\u89e3\u51b3\u529e\u6cd5:&quot;test.php?a=&quot;.urlencode(\u4f60\u597d).&quot;&amp;b=&quot;.urlencode(\u4f60\u4e5f\u597d)<br \/>\n&#8230;&#8230;&#8230;&#8230;. <\/p>\n<p>\u30103\u3011win32\u4e0b\u7684session\u4e0d\u80fd\u6b63\u5e38\u5de5\u4f5c<br \/>\nphp.ini\u9ed8\u8ba4\u7684session.save_path = \/tmp<br \/>\n<!--more-->\u8fd9\u663e\u7136\u662flinux\u4e0b\u7684\u914d\u7f6e\uff0cwin32\u4e0bphp\u65e0\u6cd5\u8bfb\u5199session\u6587\u4ef6\u5bfc\u81f4session\u65e0\u6cd5\u4f7f\u7528<br \/>\n\u628a\u5b83\u6539\u6210\u4e00\u4e2a\u7edd\u5bf9\u8def\u5f84\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f8b\u5982session.save_path = c:windows emp <\/p>\n<p>\u30104\u3011\u663e\u793a\u9519\u8bef\u4fe1\u606f<br \/>\n\u5f53php.ini\u7684display_errors = On\u5e76\u4e14error_reporting = E_ALL\u65f6\uff0c\u5c06\u663e\u793a\u6240\u6709\u7684\u9519\u8bef\u548c\u63d0\u793a\uff0c\u8c03\u8bd5\u7684\u65f6\u5019\u6700\u597d\u6253\u5f00\u4ee5\u4fbf\u7ea0\u9519\uff0c\u5982\u679c\u4f60\u7528\u4ee5\u524dphp\u5199\u6cd5\u9519\u8bef\u4fe1\u606f\u591a\u534a\u662f\u5173\u4e8e\u672a\u5b9a\u4e49\u53d8\u91cf\u7684\u3002\u53d8\u91cf\u5728\u8d4b\u503c\u4ee5\u524d\u8c03\u7528\u4f1a\u6709\u63d0\u793a\uff0c\u89e3\u51b3\u529e\u6cd5\u662f\u63a2\u6d4b\u6216\u8005\u5c4f\u853d<br \/>\n\u4f8b\u5982\u663e\u793a$foo\uff0c\u53ef\u4ee5if(isset($foo)) echo $foo \u6216\u8005echo @$foo <\/p>\n<p>\u30105\u3011Win32\u4e0bmail()\u4e0d\u80fd\u53d1\u9001\u7535\u5b50\u90ae\u4ef6<br \/>\n\u5728linux\u4e0b\u914d\u7f6e\u597d\u7684sendmail\u53ef\u4ee5\u53d1\u9001\uff0c\u5728win32\u4e0b\u9700\u8981\u8c03\u7528smtp\u670d\u52a1\u5668\u6765\u53d1\u9001\u7535\u5b50\u90ae\u4ef6<br \/>\n\u4fee\u6539php.ini\u7684SMTP = ip \/\/ip\u662f\u4e0d\u5e26\u9a8c\u8bc1\u529f\u80fd\u7684smtp\u670d\u52a1\u5668(\u7f51\u4e0a\u5f88\u96be\u627e\u5230)<br \/>\nphp\u53d1\u9001\u90ae\u4ef6\u7684\u6700\u597d\u89e3\u51b3\u65b9\u6cd5\u662f\u7528socket\u76f4\u63a5\u53d1\u9001\u5230\u5bf9\u65b9email\u670d\u52a1\u5668\u800c\u4e0d\u7528\u8f6c\u53d1\u670d\u52a1\u5668 <\/p>\n<p>\u30106\u3011\u521d\u88c5\u7684mysql\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\uff0c\u5e94\u8be5\u4f7f\u7528<br \/>\nupdate mysql.user set password=&quot;yourpassword&quot; where user=&quot;root&quot;<br \/>\n\u4fee\u6539\u5bc6\u7801 <\/p>\n<p>\u30107\u3011header already sent<br \/>\n\u8fd9\u4e2a\u9519\u8bef\u901a\u5e38\u4f1a\u5728\u4f60\u4f7f\u7528HEADER\u7684\u65f6\u5019\u51fa\u73b0\uff0c\u4ed6\u53ef\u80fd\u662f\u51e0\u79cd\u539f\u56e0\uff1a1\uff0c\u4f60\u5728\u4f7f\u7528HEADER\u524dPRING\u6216\u8005ECHO\u4e862.\u4f60\u5f53\u524d\u6587\u4ef6\u524d\u9762\u6709\u7a7a\u884c3.\u4f60\u53ef\u80fdINCLUDE\u4e86\u4e00\u4e2a\u6587\u4ef6,\u8be5\u6587\u4ef6\u5c3e\u90e8\u6709\u7a7a\u884c\u6216\u8005\u8f93\u51fa\u4e5f\u4f1a\u51fa\u73b0\u8fd9\u79cd\u9519\u8bef\u3002\uff01 <\/p>\n<p>\u30108\u3011\u66f4\u6539php.ini\u540e\u6ca1\u6709\u53d8\u5316<br \/>\n\u91cd\u65b0\u542f\u52a8web server\uff0c\u6bd4\u5982IIS\uff0cApache\u7b49\u7b49\uff0c\u7136\u540e\u624d\u4f1a\u5e94\u7528\u6700\u65b0\u7684\u8bbe\u7f6e <\/p>\n<p>\u30109\u3011php\u57282003\u4e0a\u9762\u5b89\u88c5\uff08ISAPI\u7684\u5b89\u88c5\u65b9\u6cd5\u6073\u8bf7\u9ad8\u624b\u6307\u6559\uff09<br \/>\nPHP4\u7684php4isapi.dll\u597d\u50cf\u548c2003\u6709\u4e9b\u51b2\u7a81\uff0c\u53ea\u80fd\u7528CGI\u6a21\u5f0f\u5b89\u88c5<br \/>\n\u6b65\u9aa4\u4e00\uff0c\u5148www.php.net \u4e0b\u5728\u4e00\u4e2a\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6211\u662f\u88c5\u7684\u662f\uff1aphp-4.2.3-installer.exe\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53bb\u627e\u6700\u65b0\u7684\u7248\u672c\uff0c\u5728\u5b89\u88c5php-4.2.3-installer.exe\u4e4b\u524d\u4fdd\u8bc1\u4f60\u7684IIS6.0\u542f\u52a8\u4e86\uff0c\u5e76\u80fd\u591f\u8bbf\u95ee\u3002\u5b89\u88c5\u597d\u4ee5\u540e\uff0c\u5728\u9ed8\u8ba4\u7f51\u7ad9&#8211;&gt;\u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e<br \/>\n\u6b65\u9aa4\u4e8c\uff1a\u70b9\u51fb web\u670d\u52a1\u6269\u5c55 &#8211;&gt;\u65b0\u5efaweb\u670d\u52a1\u6269\u5c55.<br \/>\n\u6b65\u9aa4\u4e09\uff1a \u6269\u5c55\u540d&#8211;&gt;php,\u7136\u540e\u6dfb\u52a0<br \/>\n\u6b65\u9aa4\u56db\uff1a\u627e\u5230php.exe\u7684\u8def\u5f84\u6dfb\u52a0\u4e0a\u53bb\u3002<br \/>\n\u6b65\u9aa4\u4e94\uff1a \u786e\u5b9a\u5c31\u53ef\u4ee5\u4e86\uff01<br \/>\n\u6b65\u9aa4\u516d\uff1a \u9009\u62e9php\u7684\u670d\u52a1\u6269\u5c55\uff0c\u7136\u540e\u70b9\u51fb\u5141\u8bb8\u3002 <\/p>\n<p>\u301010\u3011<br \/>\n\u6709\u65f6\u5019sql\u8bed\u53e5\u4e0d\u8d77\u4f5c\u7528\uff0c\u5bf9\u6570\u636e\u5e93\u64cd\u4f5c\u5931\u8d25<br \/>\n\u6700\u7b80\u4fbf\u7684\u8c03\u8bd5\u65b9\u6cd5\uff0cecho\u90a3\u53e5sql\uff0c\u770b\u770b\u53d8\u91cf\u7684\u503c\u80fd\u5f97\u5230\u4e0d <\/p>\n<p>\u301011\u3011include\u548crequire\u7684\u533a\u522b<br \/>\n\u4e24\u8005\u6ca1\u6709\u592a\u5927\u7684\u533a\u522b\uff0c\u5982\u679c\u8981\u5305\u542b\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\uff0cinclude\u63d0\u793anotice\uff0c\u7136\u540e\u7ee7\u7eed\u6267\u884c\u4e0b\u9762\u7684\u8bed\u53e5\uff0crequire\u63d0\u793a\u81f4\u547d\u9519\u8bef\u5e76\u4e14\u9000\u51fa<br \/>\n\u636e\u6211\u6d4b\u8bd5\uff0cwin32\u5e73\u53f0\u4e0b\u5b83\u4eec\u90fd\u662f\u5148\u5305\u542b\u540e\u6267\u884c\uff0c\u6240\u4ee5\u88ab\u5305\u542b\u6587\u4ef6\u91cc\u6700\u597d\u4e0d\u8981\u518d\u6709include\u6216require\u8bed\u53e5\uff0c\u8fd9\u6837\u4f1a\u9020\u6210\u76ee\u5f55\u6df7\u4e71\u3002\u6216\u8bb8*nux\u4e0b\u60c5\u51b5\u4e0d\u540c\uff0c\u6682\u65f6\u8fd8\u6ca1\u6d4b\u8bd5<br \/>\n\u5982\u679c\u4e00\u4e2a\u6587\u4ef6\u4e0d\u60f3\u88ab\u5305\u542b\u591a\u6b21\u53ef\u4ee5\u4f7f\u7528include_once\u6216require_once## \u8bfb\u53d6\uff0c\u5199\u5165\u6587\u6863\u6570\u636e<br \/>\nfunction r($file_name) {<br \/>\n$filenum=@fopen($file_name,&quot;r&quot;);<br \/>\n@flock($filenum,LOCK_SH);<br \/>\n$file_data=@fread($filenum,filesize($file_name));<br \/>\n@fclose($filenum);<br \/>\nreturn $file_data;<br \/>\n}<br \/>\nfunction w($file_name,$data,$method=&quot;w&quot;){<br \/>\n$filenum=@fopen($file_name,$method);<br \/>\nflock($filenum,LOCK_EX);<br \/>\n$file_data=fwrite($filenum,$data);<br \/>\nfclose($filenum);<br \/>\nreturn $file_data;<br \/>\n} <\/p>\n<p>\u301012\u3011isset()\u548cempty()\u7684\u533a\u522b<br \/>\n\u4e24\u8005\u90fd\u662f\u6d4b\u8bd5\u53d8\u91cf\u7528\u7684<br \/>\n\u4f46\u662fisset()\u662f\u6d4b\u8bd5\u53d8\u91cf\u662f\u5426\u88ab\u8d4b\u503c\uff0c\u800cempty()\u662f\u6d4b\u8bd5\u4e00\u4e2a\u5df2\u7ecf\u88ab\u8d4b\u503c\u7684\u53d8\u91cf\u662f\u5426\u4e3a\u7a7a<br \/>\n\u5982\u679c\u4e00\u4e2a\u53d8\u91cf\u6ca1\u88ab\u8d4b\u503c\u5c31\u5f15\u7528\u5728php\u91cc\u662f\u88ab\u5141\u8bb8\u7684,\u4f46\u4f1a\u6709notice\u63d0\u793a<br \/>\n\u5982\u679c\u4e00\u4e2a\u53d8\u91cf\u88ab\u8d4b\u7a7a\u503c\uff0c$foo=&quot;&quot;\u6216\u8005$foo=0\u6216\u8005 $foo=false,\u90a3\u4e48empty($foo)\u8fd4\u56de\u771f\uff0cisset($foo)\u4e5f\u8fd4\u56de\u771f\uff0c\u5c31\u662f\u8bf4\u8d4b\u7a7a\u503c\u4e0d\u4f1a\u6ce8\u9500\u4e00\u4e2a\u53d8\u91cf\u3002<br \/>\n\u8981\u6ce8\u9500\u4e00\u4e2a\u53d8\u91cf\uff0c\u53ef\u4ee5\u7528 unset($foo)\u6216\u8005$foo=NULL <\/p>\n<p>\u301013\u3011mysql\u67e5\u8be2\u8bed\u53e5\u5305\u542b\u6709\u5173\u952e\u5b57<br \/>\nphp\u67e5\u8be2mysql\u7684\u65f6\u5019\uff0c\u6709\u65f6\u5019mysql\u8868\u540d\u6216\u8005\u5217\u540d\u4f1a\u6709\u5173\u952e\u5b57<br \/>\n\u8fd9\u65f6\u5019\u67e5\u8be2\u4f1a\u6709\u9519\u8bef\u3002\u4f8b\u5982\u8868\u540d\u662forder,\u67e5\u8be2\u65f6\u5019\u4f1a\u51fa\u9519<br \/>\n\u7b80\u5355\u7684\u529e\u6cd5\u662fsql\u8bed\u53e5\u91cc\u8868\u540d\u6216\u8005\u5217\u540d\u52a0\u4e0a`[tab\u952e\u4e0a\u9762]\u6765\u52a0\u4ee5\u533a\u522b<br \/>\n\u4f8b\u5982select * from `order` <\/p>\n<p>\u301014\u3011\u901a\u8fc7HTTP\u534f\u8bae\u4e00\u6b21\u4e0a\u4f20\u591a\u4e2a\u6587\u4ef6\u7684\u65b9\u6cd5<br \/>\n\u6709\u4e24\u4e2a\u601d\u8def\uff0c\u662f\u540c\u4e00\u4e2a\u65b9\u6cd5\u7684\u4e24\u79cd\u5b9e\u73b0\u3002\u5177\u4f53\u7a0b\u5e8f\u8fd8\u9700\u81ea\u5df1\u53bb\u8bbe\u8ba1<br \/>\n1,\u5728form\u4e2d\u8bbe\u7f6e\u591a\u4e2a\u6587\u4ef6\u8f93\u5165\u6846\uff0c\u7528\u6570\u7ec4\u547d\u540d\u4ed6\u4eec\u7684\u540d\u5b57\uff0c\u5982\u4e0b\uff1a<br \/>\n&lt;form action=&quot;&quot; method=post&gt;<br \/>\n&lt;input type=file name=usefile[]&gt;<br \/>\n&lt;input type=file name=usefile[]&gt;<br \/>\n&lt;input type=file name=usefile[]&gt;<br \/>\n&lt;\/form&gt;<br \/>\n\u8fd9\u6837\uff0c\u5728\u670d\u52a1\u5668\u7aef\u505a\u4ee5\u4e0b\u6d4b\u8bd5<br \/>\necho &quot;&lt;pre&gt;&quot;;<br \/>\nprint_r($_FILES);<br \/>\necho &quot;&lt;\/pre&gt;&quot;; <\/p>\n<p>1,\u5728form\u4e2d\u8bbe\u7f6e\u591a\u4e2a\u6587\u4ef6\u8f93\u5165\u6846\uff0c\u4f46\u540d\u5b57\u4e0d\u540c\uff0c\u5982\u4e0b\uff1a<br \/>\n&lt;form action=&quot;&quot; method=post&gt;<br \/>\n&lt;input type=file name=usefile_a&gt;<br \/>\n&lt;input type=file name=usefile_b&gt;<br \/>\n&lt;input type=file name=usefile_c&gt;<br \/>\n&lt;\/form&gt;<br \/>\n\u5728\u670d\u52a1\u5668\u7aef\u505a\u540c\u6837\u6d4b\u8bd5\uff1a<br \/>\necho &quot;&lt;pre&gt;&quot;;<br \/>\nprint_r($_FILES);<br \/>\necho &quot;&lt;\/pre&gt;&quot;;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1awzpwhw \u4e2d\u6587PHP\u8bba\u575b \u30101\u3011\u9875\u9762\u4e4b\u95f4\u65e0\u6cd5\u4f20\u9012\u53d8\u91cf get,post,session\u5728\u6700\u65b0\u7684php [&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":[],"tags":[],"class_list":["post-373","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373"}],"version-history":[{"count":0,"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}