http_parse_headers 和 PECL_HTTP

http_parse_headers with PECL_HTTP

我想使用 http_parse_headers 所以,我安装了依赖项 pecl_http(2.4.3/2.2.5) 并调用了 http_parse_headers 函数但没有成功。

function_exists() 总是失败有什么我在这里遗漏的吗?

我正在使用

CentOS 6.7(最终版)

阿帕奇 2.4.16

PHP 5.6

更新 1

这是代码!

<?PHP
    if(function_exists("http_parse_headers")) echo 'Function Exists';
    else echo 'Function Not Exists';
?>

更新 2

这里是 php.ini

......
......
extension=pdo.so
extension=pdo_sqlite.so
extension="memcache.so"
extension="raphf.so"
extension="propro.so"
extension="http.so"
extension=pdo_mysql.so

更新 3

这是phpinfo()

的输出

PHP 文档不正确。库的版本 2 与 php.net.

中列出的函数不兼容

这样阅读 new documentation you now have to use HTTP::parse

http\Header::parse($yourHeaders)

好的,经过长时间的搜索我发现

Version 2 of PECL_HTTP library is COMPLETELY INCOMPATIBLE with Version 1 None of the HTTP functions exists in Version 2

PHP.net 上的文档中没有任何说明。

顺便说一下,Version 2 is a completely OOP interface and drops support for all the functions listed here 在文档中。

如果您正在寻找函数 API,请使用 Version 1

所以,按照 Ricardo 的建议,您需要使用

http\Header::parse($yourHeaders);

解析header和

new http\Cookie($yourCookies);

解析 cookie 等