{"id":181578,"date":"2024-05-08T21:00:35","date_gmt":"2024-05-08T13:00:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/181578.html"},"modified":"2024-05-08T21:00:40","modified_gmt":"2024-05-08T13:00:40","slug":"ci%e6%a1%86%e6%9e%b62-2%e7%89%88%e6%9c%ac%e8%83%bd%e4%bd%bf%e7%94%a8php7-2%e5%90%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/181578.html","title":{"rendered":"CI\u6846\u67b62.2\u7248\u672c\u80fd\u4f7f\u7528php7.2\u5417"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27071319\/3bc58513-c19b-4181-b12a-8686e4cb61e5.webp\" alt=\"CI\u6846\u67b62.2\u7248\u672c\u80fd\u4f7f\u7528php7.2\u5417\" \/><\/p>\n<p><p>CI\u6846\u67b6\uff08CodeIgniter\uff092.2\u7248\u672c<strong>\u4e0d\u5b8c\u5168\u517c\u5bb9PHP 7.2<\/strong>\uff0c\u8fd9\u662f\u56e0\u4e3a\u81eaPHP 7.0\u8d77\uff0c\u5f88\u591a\u88ab\u5e9f\u5f03\u7684\u529f\u80fd\u88ab\u79fb\u9664\u3001\u65b0\u7684\u7279\u6027\u88ab\u5f15\u5165\uff0c\u5bfc\u81f4\u4e0d\u517c\u5bb9\u95ee\u9898\u3002\u6bd4\u5982\uff0c\u5728PHP 7.2\u4e2d\u5df2\u7ecf\u79fb\u9664\u4e86 <code>create_function()<\/code>\uff0c\u8fd9\u5728\u8f83\u8001\u65e7\u7684CI\u7248\u672c\u4e2d\u53ef\u80fd\u88ab\u4f7f\u7528\u3002\u5efa\u8bae\u5347\u7ea7\u5230CI\u76843.x\u7248\u672c\uff0c\u6216\u8005\u8fdb\u884c\u5fc5\u8981\u7684\u4fee\u6539\u6765\u9002\u914dPHP 7.2\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u517c\u5bb9\u6027\u95ee\u9898\u4e0e\u89e3\u51b3\u7b56\u7565<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u65e7\u7248\u672c\u7684CI\u6846\u67b6\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u56e0\u4e3a\u8fd9\u4e9b\u7248\u672c\u5e76\u672a\u8bbe\u8ba1\u7528\u4e8e\u9002\u914d\u8f83\u65b0\u7248\u672c\u7684PHP\u800c\u51fa\u73b0\u7684\u517c\u5bb9\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h4><strong>\u5e9f\u5f03\u7684\u51fd\u6570\u548c\u7279\u6027<\/strong><\/h4>\n<\/p>\n<p><p>PHP 7.2\u5220\u9664\u6216\u66f4\u6539\u4e86\u4e00\u4e9b\u5728\u4ee5\u524d\u7248\u672c\u4e2d\u53ef\u4ee5\u4f7f\u7528\u7684\u51fd\u6570\u548c\u7279\u6027\u3002\u4f8b\u5982\uff0c<code>each()<\/code> \u51fd\u6570\u88ab\u5e9f\u5f03\uff0c<code>Object<\/code> \u4e0d\u518d\u53ef\u4ee5\u4f5c\u4e3a\u7c7b\u540d\u7684\u4e00\u90e8\u5206\u3002\u5728CI 2.2\u7248\u672c\u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u8fd9\u4e9b\u529f\u80fd\uff0c\u5219\u9700\u8981\u8fdb\u884c\u6539\u52a8\u3002<\/p>\n<\/p>\n<p><h4><strong>\u9519\u8bef\u5904\u7406\u548c\u5f02\u5e38<\/strong><\/h4>\n<\/p>\n<p><p>PHP 7 \u5f15\u5165\u4e86\u9519\u8bef\u5904\u7406\u673a\u5236\u7684\u53d8\u5316\uff0c\u73b0\u5728\u9519\u8bef\u4f1a\u88ab\u4f5c\u4e3a\u5f02\u5e38\u629b\u51fa\u3002\u8fd9\u53ef\u80fd\u4f1a\u5f71\u54cdCI\u6846\u67b6\u7684\u9519\u8bef\u7ba1\u7406\u7cfb\u7edf\uff0c\u56e0\u6b64\u9002\u914d\u65f6\uff0c\u4e5f\u9700\u8981\u8003\u8651\u5f02\u5e38\u6355\u83b7\u548c\u5904\u7406\u903b\u8f91\u7684\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u63d0\u5347\u6846\u67b6\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5347\u7ea7\u6846\u67b6\u81f3\u5c11\u5230CI 3.x \u7248\u672c\uff0c\u6700\u597d\u662f\u5230\u6700\u65b0\u7248\u672c\uff08\u5982\u679c\u6709\uff09\u3002CI 3.x \u6539\u8fdb\u4e86\u5f88\u591a\u6838\u5fc3\u529f\u80fd\u5e76\u4e14\u589e\u52a0\u4e86\u5bf9\u66f4\u9ad8\u7248\u672cPHP\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<p><h4><strong>\u6539\u8fdb\u7684\u5b89\u5168\u6027<\/strong><\/h4>\n<\/p>\n<p><p>CI 3.x \u589e\u5f3a\u4e86\u5b89\u5168\u7279\u6027\uff0c\u5305\u62ecXSS\u8fc7\u6ee4\u548cSQL\u6ce8\u5165\u9632\u5fa1\u7b49\u3002<\/p>\n<\/p>\n<p><h4><strong>\u66f4\u597d\u7684\u6027\u80fd<\/strong><\/h4>\n<\/p>\n<p><p>CI 3.x \u5bf9\u6846\u67b6\u7684\u6027\u80fd\u4e5f\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u5728\u5904\u7406\u8bf7\u6c42\u548c\u6570\u636e\u5e93\u4ea4\u4e92\u65b9\u9762\u66f4\u4e3a\u9ad8\u6548\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4fee\u6539\u548c\u6d4b\u8bd5\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4e0d\u6253\u7b97\u5347\u7ea7CI\u7248\u672c\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u5bf9\u73b0\u6709\u7684CI 2.2\u7248\u672c\u4ee3\u7801\u8fdb\u884c\u624b\u52a8\u4fee\u6539\u4ee5\u9002\u914dPHP 7.2\u3002<\/p>\n<\/p>\n<p><h4><strong>\u4fee\u6539\u5e9f\u5f03\u7684\u4ee3\u7801<\/strong><\/h4>\n<\/p>\n<p><p>\u624b\u52a8\u53bb\u9664\u6216\u66ff\u6362\u6240\u6709\u4e0d\u517c\u5bb9PHP 7.2\u7684\u529f\u80fd\u548c\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u5c06 <code>mysql_*<\/code> \u51fd\u6570\u6539\u4e3a\u4f7f\u7528 <code>mysqli_*<\/code> \u6216PDO\u98ce\u683c\u3002<\/p>\n<\/p>\n<p><h4><strong>\u4e25\u683c\u7684\u6d4b\u8bd5<\/strong><\/h4>\n<\/p>\n<p><p>\u5728\u6539\u52a8\u540e\uff0c\u5fc5\u987b\u8fdb\u884c\u5f7b\u5e95\u7684\u6d4b\u8bd5\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u529f\u80fd\u4ecd\u7136\u6309\u9884\u671f\u5de5\u4f5c\u3002\u7279\u522b\u662f\u8981\u6ce8\u610f\u6570\u636e\u5e93\u4ea4\u4e92\u548c\u8868\u5355\u63d0\u4ea4\u7b49\u65b9\u9762\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u8003\u8651\u66ff\u4ee3\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u53d1\u73b0\u4fee\u6539\u5de5\u4f5c\u91cf\u592a\u5927\u6216\u8005\u4e0d\u5212\u7b97\uff0c\u53ef\u4ee5\u8003\u8651\u91c7\u7528\u66ff\u4ee3\u65b9\u6848\uff0c\u6bd4\u5982\u8fc1\u79fb\u5230\u5176\u4ed6\u6846\u67b6\u6216\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u5c01\u88c5\u6765\u66ff\u6362\u6389\u65e7\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4><strong>\u8fc1\u79fb\u5230\u5176\u4ed6\u6846\u67b6<\/strong><\/h4>\n<\/p>\n<p><p>\u8003\u5bdf\u5e02\u573a\u4e0a\u5176\u4ed6\u6846\u67b6\u7684\u517c\u5bb9\u6027\u548c\u529f\u80fd\uff0c\u5982Laravel\u3001Symfony\u7b49\uff0c\u5b83\u4eec\u53ef\u80fd\u5df2\u7ecf\u5177\u5907\u826f\u597d\u7684PHP 7.2\u652f\u6301\u3002<\/p>\n<\/p>\n<p><h4><strong>\u5c01\u88c5\u66ff\u4ee3\u7ec4\u4ef6<\/strong><\/h4>\n<\/p>\n<p><p>\u5982\u679cCI\u6846\u67b6\u7684\u67d0\u4e9b\u90e8\u5206\u662f\u9879\u76ee\u6240\u5fc5\u9700\u7684\uff0c\u800c\u4e14\u96be\u4ee5\u66ff\u6362\uff0c\u53ef\u4ee5\u8003\u8651\u5199\u4e00\u4e2a\u517c\u5bb9\u5c42\u6216\u8005\u4f7f\u7528\u793e\u533a\u63d0\u4f9b\u7684\u8865\u4e01\u6765\u89e3\u51b3\u7279\u5b9a\u7684\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u867d\u7136CI\u6846\u67b62.2\u7248\u672c\u4e0d\u5b8c\u5168\u517c\u5bb9PHP 7.2\uff0c\u4f46\u5b58\u5728\u5347\u7ea7\u6846\u67b6\u3001\u4fee\u6539\u4e0d\u517c\u5bb9\u4ee3\u7801\u6216\u8fc1\u79fb\u5230\u5176\u4ed6\u6846\u67b6\u7b49\u89e3\u51b3\u65b9\u6848\u3002\u5f00\u53d1\u56e2\u961f\u9700\u8981\u6839\u636e\u9879\u76ee\u7684\u5177\u4f53\u9700\u6c42\u3001\u8d44\u6e90\u4ee5\u53ca\u65f6\u95f4\u6210\u672c\uff0c\u6743\u8861\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u5728\u8fdb\u884c\u7248\u672c\u5347\u7ea7\u6216\u4ee3\u7801\u6539\u9020\u65f6\uff0c<strong>\u5e94\u5145\u5206\u6d4b\u8bd5\u6240\u6709\u7684\u529f\u80fd\u70b9\u4ee5\u786e\u4fdd\u5b83\u4eec\u5728\u65b0\u73af\u5883\u4e2d\u80fd\u6b63\u5e38\u8fd0\u884c<\/strong>\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. CI\u6846\u67b62.2\u7248\u672c\u662f\u5426\u517c\u5bb9php7.2?<\/strong><br \/>\nYes, CI\u6846\u67b62.2\u7248\u672c\u53ef\u4ee5\u4f7f\u7528php7.2\u3002CI\u6846\u67b6\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684PHP\u6846\u67b6\uff0c\u5177\u6709\u5f88\u597d\u7684\u53ef\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002\u867d\u71362.2\u7248\u672c\u76f8\u5bf9\u8f83\u65e7\uff0c\u4f46\u5b83\u4ecd\u7136\u53ef\u4ee5\u5728php7.2\u4e0a\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p><strong>2. CI\u6846\u67b62.2\u7248\u672c\u5728php7.2\u4e0a\u7684\u6027\u80fd\u5982\u4f55?<\/strong><br \/>\n\u5c3d\u7ba1CI\u6846\u67b62.2\u662f\u4e00\u79cd\u76f8\u5bf9\u8f83\u65e7\u7684\u7248\u672c\uff0c\u4f46\u5b83\u5728php7.2\u4e0a\u7684\u6027\u80fd\u4ecd\u7136\u53ef\u4ee5\u8fbe\u5230\u8f83\u9ad8\u6c34\u5e73\u3002\u4f46\u8bf7\u6ce8\u610f\uff0c\u76f8\u5bf9\u4e8e\u8f83\u65b0\u7248\u672c\u7684CI\u6846\u67b6\uff0c2.2\u7248\u672c\u53ef\u80fd\u5728\u4e00\u4e9b\u9ad8\u8d1f\u8f7d\u73af\u5883\u4e0b\u7684\u6027\u80fd\u7565\u4f4e\u3002<\/p>\n<p><strong>3. \u6211\u5e94\u8be5\u5347\u7ea7CI\u6846\u67b6\u5230\u6700\u65b0\u7248\u672c\u8fd8\u662f\u7ee7\u7eed\u4f7f\u75282.2\u7248\u672c?<\/strong><br \/>\n\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u7684CI\u6846\u67b6\u901a\u5e38\u662f\u4e00\u4e2a\u660e\u667a\u7684\u9009\u62e9\uff0c\u56e0\u4e3a\u6700\u65b0\u7248\u672c\u901a\u5e38\u5177\u6709\u66f4\u597d\u7684\u6027\u80fd\uff0c\u66f4\u591a\u529f\u80fd\u548c\u66f4\u597d\u7684\u5b89\u5168\u6027\u3002\u4f46\u5982\u679c\u60a8\u7684\u9879\u76ee\u5df2\u7ecf\u5728CI\u6846\u67b62.2\u4e0a\u5e76\u4e14\u6ca1\u6709\u9047\u5230\u95ee\u9898\uff0c\u4f60\u4e5f\u53ef\u4ee5\u7ee7\u7eed\u4f7f\u75282.2\u7248\u672c\u3002\u5728\u505a\u51fa\u51b3\u5b9a\u65f6\uff0c\u60a8\u5e94\u8be5\u6743\u8861\u9879\u76ee\u9700\u6c42\uff0c\u53ef\u7528\u7684\u8d44\u6e90\u4ee5\u53ca\u9700\u8981\u7684\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"CI\u6846\u67b6\uff08CodeIgniter\uff092.2\u7248\u672c\u4e0d\u5b8c\u5168\u517c\u5bb9PHP 7.2\uff0c\u8fd9\u662f\u56e0\u4e3a\u81eaPHP 7.0\u8d77\uff0c\u5f88\u591a\u88ab\u5e9f\u5f03\u7684 [&hellip;]","protected":false},"author":3,"featured_media":181585,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/181578"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=181578"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/181578\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/181585"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=181578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=181578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=181578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}