gpt4 book ai didi

php - 如何在没有 PECL 的情况下获得 http_parse_headers 的功能?

转载 作者:可可西里 更新时间:2023-11-01 15:08:42 26 4
gpt4 key购买 nike

我在 Windows 上使用 PHP 5.3.5,但我没有找到任何适用于我的安装的 pecl_http.dll

所以我的问题是,

如何获得 http_parse_headers 的功能不使用 PECL?

最佳答案

从文档页面,第一条评论:

 if( !function_exists( 'http_parse_headers' ) ) {
function http_parse_headers( $header )
{
$retVal = array();
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
foreach( $fields as $field ) {
if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
if( isset($retVal[$match[1]]) ) {
$retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
} else {
$retVal[$match[1]] = trim($match[2]);
}
}
}
return $retVal;
}
}

或者,您可能想阅读如何在 Windows 上安装 PECL 扩展,老实说,我对此一无所知。

关于php - 如何在没有 PECL 的情况下获得 http_parse_headers 的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6368574/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com