{"id":591,"date":"2024-12-29T23:37:34","date_gmt":"2024-12-29T15:37:34","guid":{"rendered":"http:\/\/www.wengdao.net\/?p=591"},"modified":"2024-12-29T23:42:55","modified_gmt":"2024-12-29T15:42:55","slug":"php-%e5%9b%9b%e5%b1%82%e4%bd%93%e7%b3%bb%e6%89%a7%e8%a1%8c%e9%a1%ba%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/jiandao.zliby.com\/?p=591","title":{"rendered":"PHP \u56db\u5c42\u4f53\u7cfb\u6267\u884c\u987a\u5e8f"},"content":{"rendered":"<h1>PHP \u56db\u5c42\u4f53\u7cfb\u6267\u884c\u987a\u5e8f<\/h1>\n<p>PHP \u7684\u5e95\u5c42\u8bbe\u8ba1\u5305\u542b <strong>Zend \u5f15\u64ce<\/strong>\u3001<strong>Extensions \u6269\u5c55<\/strong>\u3001<strong>SAPI \u63a5\u53e3<\/strong> \u548c <strong>\u4e0a\u5c42\u5e94\u7528<\/strong> \u56db\u4e2a\u4e3b\u8981\u5c42\u6b21\u3002\u57fa\u4e8e PHP \u7684\u8bbe\u8ba1\u539f\u7406\uff0c\u6574\u7406\u7684\u5404\u4e2a\u5c42\u6b21\u53ca\u5176\u529f\u80fd\uff1a<\/p>\n<p>\u5982\u56fe\uff1a<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.wengdao.net\/wp-content\/uploads\/2024\/12\/a249f0868f2b2967945ea7e84197521d.png\" alt=\"\" \/><\/p>\n<h2>1. SAPI \u63a5\u53e3 (Server API)<\/h2>\n<ul>\n<li><strong>\u6267\u884c\u987a\u5e8f<\/strong>\uff1a\u7b2c\u4e00\u5c42<\/li>\n<li>\n<p><strong>\u529f\u80fd<\/strong>\uff1aSAPI\uff08Server API\uff09\u63a5\u53e3\u662f PHP \u4e0e Web \u670d\u52a1\u5668\u3001\u547d\u4ee4\u884c\u6216\u5176\u4ed6\u8fd0\u884c\u73af\u5883\u4e4b\u95f4\u7684\u6865\u6881\u3002\u5b83\u8d1f\u8d23\u63a5\u6536\u5916\u90e8\u8bf7\u6c42\uff0c\u5e76\u5c06\u8bf7\u6c42\u4fe1\u606f\u4f20\u9012\u7ed9 PHP \u5f15\u64ce\u3002<\/p>\n<ul>\n<li><strong>Web \u8bf7\u6c42<\/strong>\uff1aSAPI \u63a5\u53e3\u63a5\u6536 HTTP \u8bf7\u6c42\uff0c\u5e76\u5c06\u5176\u4f20\u9012\u7ed9 PHP \u5f15\u64ce\uff08\u5982 <code class=\"prettyprint\" >mod_php<\/code>\u3001<code>PHP-FPM<\/code>\uff09\u3002<\/li>\n<li><strong>\u547d\u4ee4\u884c<\/strong>\uff1a\u5728 CLI \u6a21\u5f0f\u4e0b\uff0cSAPI \u63a5\u53e3\u8d1f\u8d23\u63a5\u6536\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u5e76\u8c03\u7528 PHP \u5f15\u64ce\u6765\u6267\u884c\u811a\u672c\u3002<\/li>\n<li><strong>FastCGI\/CGI<\/strong>\uff1a\u5982\u679c\u4f7f\u7528 FastCGI \u6216 CGI\uff0cSAPI \u63a5\u53e3\u4e5f\u5904\u7406\u4e0e Web \u670d\u52a1\u5668\u7684\u901a\u4fe1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u603b\u7ed3<\/strong>\uff1aSAPI \u662f\u4e0e\u5916\u90e8\u4e16\u754c\u7684\u63a5\u53e3\uff0c\u8d1f\u8d23\u63a5\u53d7\u7528\u6237\u8bf7\u6c42\u5e76\u5c06\u5176\u4f20\u9012\u7ed9 Zend \u5f15\u64ce\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<h2>2. Zend \u5f15\u64ce (Zend Engine)<\/h2>\n<ul>\n<li><strong>\u6267\u884c\u987a\u5e8f<\/strong>\uff1a\u7b2c\u4e8c\u5c42<\/li>\n<li>\n<p><strong>\u529f\u80fd<\/strong>\uff1aZend \u5f15\u64ce\u662f PHP \u7684\u6838\u5fc3\u6267\u884c\u5f15\u64ce\uff0c\u8d1f\u8d23\u5c06 PHP \u6e90\u4ee3\u7801\u89e3\u6790\u3001\u7f16\u8bd1\u5e76\u6267\u884c\u3002Zend \u5f15\u64ce\u5c06 PHP \u4ee3\u7801\u8f6c\u6362\u4e3a\u64cd\u4f5c\u7801\uff08OpCode\uff09\uff0c\u7136\u540e\u4ea4\u7531 Zend \u865a\u62df\u673a\u6267\u884c\u3002<\/p>\n<ul>\n<li><strong>\u89e3\u6790\u8fc7\u7a0b<\/strong>\uff1aPHP \u6e90\u4ee3\u7801\u7ecf\u8fc7\u8bcd\u6cd5\u5206\u6790\uff08Tokenization\uff09\u3001\u8bed\u6cd5\u5206\u6790\uff08Parsing\uff09\u751f\u6210\u62bd\u8c61\u8bed\u6cd5\u6811\uff08AST\uff09\uff0c\u5e76\u751f\u6210\u64cd\u4f5c\u7801\uff08OpCode\uff09\u3002<\/li>\n<li><strong>\u6267\u884c\u8fc7\u7a0b<\/strong>\uff1aZend \u5f15\u64ce\u901a\u8fc7 Zend \u865a\u62df\u673a\u9010\u6761\u6267\u884c\u64cd\u4f5c\u7801\uff0c\u5b8c\u6210\u4e1a\u52a1\u903b\u8f91\u3002<\/li>\n<li><strong>\u5185\u5b58\u7ba1\u7406<\/strong>\uff1aZend \u5f15\u64ce\u8d1f\u8d23\u5185\u5b58\u5206\u914d\u548c\u5783\u573e\u56de\u6536\uff0c\u786e\u4fdd\u8d44\u6e90\u7684\u9ad8\u6548\u5229\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u603b\u7ed3<\/strong>\uff1aZend \u5f15\u64ce\u662f PHP \u4ee3\u7801\u6267\u884c\u7684\u6838\u5fc3\uff0c\u5b83\u5c06 PHP \u6e90\u4ee3\u7801\u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u7684\u64cd\u4f5c\u7801\u5e76\u6267\u884c\u3002<\/p>\n<h2>3. Extensions \u6269\u5c55<\/h2>\n<ul>\n<li><strong>\u6267\u884c\u987a\u5e8f<\/strong>\uff1a\u7b2c\u4e09\u5c42<\/li>\n<li>\n<p><strong>\u529f\u80fd<\/strong>\uff1aPHP \u6269\u5c55\uff08Extensions\uff09\u662f\u7528 C \u8bed\u8a00\u7f16\u5199\u7684\u6a21\u5757\uff0c\u5b83\u4eec\u4e3a PHP \u63d0\u4f9b\u989d\u5916\u7684\u529f\u80fd\u3002\u901a\u8fc7\u6269\u5c55\uff0cPHP \u53ef\u4ee5\u4e0e\u5916\u90e8\u5e93\u3001\u7cfb\u7edf\u670d\u52a1\u6216\u786c\u4ef6\u4ea4\u4e92\u3002<\/p>\n<ul>\n<li><strong>\u52a0\u8f7d\u4e0e\u521d\u59cb\u5316<\/strong>\uff1aPHP \u542f\u52a8\u65f6\uff0c\u6839\u636e\u914d\u7f6e\u6587\u4ef6\uff08\u5982 <code class=\"prettyprint\" >php.ini<\/code>\uff09\u52a0\u8f7d\u6269\u5c55\u3002<\/li>\n<li><strong>\u529f\u80fd\u589e\u5f3a<\/strong>\uff1a\u6269\u5c55\u63d0\u4f9b\u6570\u636e\u5e93\u64cd\u4f5c\uff08\u5982 <code class=\"prettyprint\" >mysqli<\/code>\uff09\u3001\u7f13\u5b58\u7ba1\u7406\uff08\u5982 <code>APCu<\/code>\uff09\u7b49\u529f\u80fd\u3002<\/li>\n<li><strong>\u4e0e Zend \u5f15\u64ce\u534f\u4f5c<\/strong>\uff1a\u6269\u5c55\u53ef\u4ee5\u76f4\u63a5\u5728 Zend \u5f15\u64ce\u4e2d\u8c03\u7528\uff0c\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u603b\u7ed3<\/strong>\uff1a\u6269\u5c55\u589e\u5f3a\u4e86 PHP \u7684\u529f\u80fd\uff0c\u5b83\u4e3a Zend \u5f15\u64ce\u63d0\u4f9b\u4e86\u4e0e\u5916\u90e8\u670d\u52a1\u7684\u63a5\u53e3\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u3001\u7f13\u5b58\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\u3002<\/p>\n<h2>4. \u4e0a\u5c42\u5e94\u7528<\/h2>\n<ul>\n<li><strong>\u6267\u884c\u987a\u5e8f<\/strong>\uff1a\u7b2c\u56db\u5c42<\/li>\n<li>\n<p><strong>\u529f\u80fd<\/strong>\uff1a\u4e0a\u5c42\u5e94\u7528\u662f\u5f00\u53d1\u8005\u7f16\u5199\u7684 PHP \u811a\u672c\u6216\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b83\u4eec\u5229\u7528 Zend \u5f15\u64ce\u548c\u6269\u5c55\u6765\u5b9e\u73b0\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n<ul>\n<li><strong>\u6267\u884c\u5e94\u7528\u903b\u8f91<\/strong>\uff1a\u4e0a\u5c42\u5e94\u7528\u63a5\u6536\u6765\u81ea\u7528\u6237\u6216\u5916\u90e8\u7cfb\u7edf\u7684\u8f93\u5165\uff0c\u8c03\u7528 Zend \u5f15\u64ce\u548c\u6269\u5c55\u5904\u7406\u4e1a\u52a1\u3002<\/li>\n<li><strong>\u6846\u67b6\u4e0e\u5e93<\/strong>\uff1a\u5927\u591a\u6570 PHP \u5e94\u7528\u90fd\u57fa\u4e8e\u6846\u67b6\uff08\u5982 Laravel\u3001Symfony\uff09\u6216\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u6765\u6784\u5efa\u3002<\/li>\n<li><strong>\u6700\u7ec8\u8f93\u51fa<\/strong>\uff1a\u4e0a\u5c42\u5e94\u7528\u751f\u6210\u8f93\u51fa\uff08\u5982 HTML\u3001JSON\u3001XML\uff09\uff0c\u5e76\u901a\u8fc7 SAPI \u63a5\u53e3\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u603b\u7ed3<\/strong>\uff1a\u4e0a\u5c42\u5e94\u7528\u5305\u542b\u5177\u4f53\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u5b83\u901a\u8fc7 Zend \u5f15\u64ce\u548c\u6269\u5c55\u5b9e\u73b0\u6570\u636e\u5904\u7406\u548c\u4efb\u52a1\u6267\u884c\uff0c\u6700\u7ec8\u5411\u7528\u6237\u6216\u7cfb\u7edf\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<h1>\u603b\u7ed3<\/h1>\n<p>PHP \u7684\u56db\u4e2a\u7ec4\u4ef6\u6309\u4ee5\u4e0b\u5c42\u6b21\u534f\u540c\u5de5\u4f5c\uff1a<\/p>\n<ol>\n<li><strong>SAPI \u63a5\u53e3<\/strong>\uff1a\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u51b3\u5b9a\u8bf7\u6c42\u7684\u6267\u884c\u6a21\u5f0f\uff08Web\u3001CLI \u7b49\uff09\uff0c\u5e76\u5c06\u8bf7\u6c42\u4f20\u9012\u7ed9 PHP \u5f15\u64ce\u3002<\/li>\n<li><strong>Zend \u5f15\u64ce<\/strong>\uff1a\u89e3\u6790\u3001\u7f16\u8bd1\u5e76\u6267\u884c PHP \u4ee3\u7801\uff0c\u751f\u6210\u64cd\u4f5c\u7801\u5e76\u901a\u8fc7\u865a\u62df\u673a\u6267\u884c\uff0c\u5904\u7406\u6838\u5fc3\u7684\u4e1a\u52a1\u903b\u8f91\u3002<\/li>\n<li><strong>Extensions \u6269\u5c55<\/strong>\uff1a\u901a\u8fc7\u52a0\u8f7d\u6269\u5c55\u6a21\u5757\u6765\u589e\u5f3a PHP \u7684\u529f\u80fd\uff0c\u6269\u5c55\u53ef\u4ee5\u76f4\u63a5\u5728 Zend \u5f15\u64ce\u4e2d\u6267\u884c\uff0c\u5982\u6570\u636e\u5e93\u64cd\u4f5c\u3001\u7f13\u5b58\u3001\u56fe\u50cf\u5904\u7406\u7b49\u3002<\/li>\n<li><strong>\u4e0a\u5c42\u5e94\u7528<\/strong>\uff1a\u5f00\u53d1\u8005\u7f16\u5199\u7684 PHP \u811a\u672c\uff0c\u901a\u8fc7 Zend \u5f15\u64ce\u548c\u6269\u5c55\u5b9e\u73b0\u5177\u4f53\u7684\u4e1a\u52a1\u903b\u8f91\u548c\u4efb\u52a1\uff0c\u6700\u7ec8\u8fd4\u56de\u54cd\u5e94\u7ed9\u7528\u6237\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u79cd\u5206\u5c42\u8bbe\u8ba1\u7684\u67b6\u6784\u6709\u52a9\u4e8e PHP \u5728\u6027\u80fd\u3001\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\u65b9\u9762\u8fbe\u5230\u5e73\u8861\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u9ad8\u6548\u5730\u6784\u5efa\u548c\u4f18\u5316 PHP \u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u56db\u5c42\u4f53\u7cfb\u6267\u884c\u987a\u5e8f PHP \u7684\u5e95\u5c42\u8bbe\u8ba1\u5305\u542b Zend \u5f15\u64ce\u3001Extensions \u6269\u5c55\u3001SAPI \u63a5\u53e3  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/591"}],"collection":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=591"}],"version-history":[{"count":2,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions"}],"predecessor-version":[{"id":594,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions\/594"}],"wp:attachment":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}