{"id":928,"date":"2023-09-11T13:02:56","date_gmt":"2023-09-11T05:02:56","guid":{"rendered":"https:\/\/blog.nonot.cn\/?p=928"},"modified":"2024-07-08T12:42:29","modified_gmt":"2024-07-08T04:42:29","slug":"php%e5%8d%87%e7%ba%a7","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2023\/09\/11\/php%e5%8d%87%e7%ba%a7\/","title":{"rendered":"PHP\u5347\u7ea7"},"content":{"rendered":"\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>1\u3001PHP7.4\u4ee5\u540e\u4e0d\u518d\u80fd\u591f\u4f7f\u7528\u82b1\u62ec\u53f7\u6765\u8bbf\u95ee\u6570\u7ec4\u6216\u8005\u5b57\u7b26\u4e32\u7684\u504f\u79fb.\u9700\u8981\u5c06{}\u4fee\u6539\u6210[] \u5c31\u53ef\u4ee5\u89e3\u51b3\u95ee\u9898<\/p>\n<p>\u82e5\u4ee3\u7801\u903b\u8f91\u4e2d\u542b\u6709\u7c7b\u4f3c<\/p>\n<p>$asc = ord($s{0}) * 256 + ord($s{1}) &#8211; 65536;<br \/>\n\u9700\u8981\u4fee\u6539\u6210<\/p>\n<p>$asc = ord($s[0]) * 256 + ord($s[1]) &#8211; 65536;<\/p>\n<\/div><\/div>\n<\/div>\n<\/div>\n\n\n<p>2\u3001php\u62a5\u9519\uff1aCall to undefined function get_magic_quotes_gpc()<\/p>\n<p>\u51fa\u73b0\u539f\u56e0\uff1a<\/p>\n<p>PHP\u7248\u672c6\u4e2d \u53d6\u6d88\u4e86get_magic_quotes_gpc()\u51fd\u6570\uff0c\u9996\u5148\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\uff1a\u662f\u4e3a\u4e86\u9632\u6b62sql\u6ce8\u5165\uff0c\u5f53\u8be5\u51fd\u6570\u6253\u5f00\u65f6\u5c06\u6240\u6709\u5355\u5f15\u53f7\uff0c\u53cc\u5f15\u53f7\uff0c\u53cd\u659c\u7ebf\u548c\u7a7a\u5b57\u7b26\u8f6c\u4f1a\u81ea\u52a8\u8f6c\u4e3a\u542b\u6709\u53cd\u659c\u7ebf\u7684\u6ea2\u51fa\u5b57\u7b26\u3002<br \/>PHP6\u53d6\u6d88magic_quotes\u673a\u5236\uff0c\u90a3\u4e48\u5c31\u662f\u9ed8\u8ba4\u8f6c\u4e49\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6765\u9632\u6b62sql\u6ce8\u5165\u3002<\/p>\n<p>\u53ef\u4ee5\u628a\u6e90\u4ee3\u7801\u6539\u4e3a\uff1a(PHP_VERSION &gt;= 6 || !get_magic_quotes_gpc())\u6216\u8005(PHP_VERSION &lt; 6 &amp;&amp; get_magic_quotes_gpc())<\/p>\n<p>\u6765\u63d0\u5347\u517c\u5bb9\u6027\u3002<\/p>\n\n<p>3\u3001PHP\u8fde\u63a5mysql\u6570\u636e\u5e93\u62a5\u9519\uff1aCall to undefined function mysql_connect()<\/p>\n<p>[client 127.0.0.1:37496] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in \/var\/www\/html\/test.php:2\\nStack trace:\\n#0 {main}\\n thrown in \/var\/www\/html\/test.php on line 2<\/p>\n<p>\u4ee3\u7801\uff1a&lt;?PHP<br \/>$conn=mysql_connect(&#8220;localhost&#8221;,&#8221;root&#8221;,&#8221;root&#8221;);<br \/>if($conn){<br \/>echo&#8221;ok&#8221;;<br \/>}else{<br \/>echo&#8221;error&#8221;; <br \/>}<br \/>?&gt;<\/p>\n<p>\u6539\u4e3a\uff1a<\/p>\n<p>\u67e5\u9605\u8d44\u6599\u540e\u53d1\u73b0\uff0c\u539f\u6765\u662f\u4ecePHP5.0\u5f00\u59cb\u5c31\u4e0d\u63a8\u8350\u4f7f\u7528mysql_connect()\u51fd\u6570\uff0c\u5230\u4e86php7.0\u5219\u76f4\u63a5\u5e9f\u5f03\u4e86\u8be5\u51fd\u6570\uff0c\u66ff\u4ee3\u7684\u51fd\u6570\u662f\uff1a<\/p>\n<p>mysqli_connect();<br \/>\u7528\u6cd5\u662f\uff1a<\/p>\n<p>$con=mysqli_connect(&#8220;localhost&#8221;,&#8221;my_user&#8221;,&#8221;my_password&#8221;,&#8221;my_db&#8221;);<br \/>\u5b98\u65b9\u7684\u63cf\u8ff0\u8fde\u63a5\uff1ahttp:\/\/php.net\/manual\/en\/function.mysqli-connect.php<br \/>\u6b63\u786e\u7684\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<p>&lt;?PHP<br \/>$conn=mysqli_connect(&#8220;localhost&#8221;,&#8221;root&#8221;,&#8221;root&#8221;);<br \/>if($conn){<br \/>echo&#8221;ok&#8221;;<br \/>}else{<br \/>echo&#8221;error&#8221;; <br \/>}<br \/>?&gt;<\/p>\n\n<p>4\u3001php\u51fa\u73b0http500\u9519\u8bef\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355,\u6253\u5f00<em>PHP<\/em>.ini,\u8bbe\u7f6e\u663e\u793a<em>\u9519\u8bef<\/em>\u00a0display_errors = On \u7136\u540e\u6253\u5f00IIS,\u91cd\u65b0\u542f\u52a8FastCGI\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>1\u3001PHP7.4\u4ee5\u540e\u4e0d\u518d\u80fd\u591f\u4f7f\u7528\u82b1\u62ec\u53f7\u6765\u8bbf\u95ee\u6570\u7ec4\u6216\u8005\u5b57\u7b26\u4e32\u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-928","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=928"}],"version-history":[{"count":6,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/928\/revisions"}],"predecessor-version":[{"id":1125,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/928\/revisions\/1125"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}