apt update apt search libidn apt -y install libidn2-0 libidn2-0-dev libidn2-dev libicu-dev apt -y install zlib1g zlib1g-dev libcurl4-openssl-dev libssl-dev libidnkit 需要编译安装,但这些不是必须的。 /opt/lampp/bin # 先安装 raphf 和 propro ./pecl install raphf ./pecl install propro # 编辑php.ini,增加 vim /opt/lampp/etc/php.ini extension="raphf.so" extension="propro.so" # 再安装pecl_http # https://pecl.php.net/package/pecl_http ./pecl search http ./pecl install pecl_http ./pecl install pecl_http-1.0.0 ./pecl install pecl_http-3.2.0 ./pecl install pecl_http-4.0.0 ./pecl list ./php -m /opt/lampp/lampp restartapache 版本1.X 以函数的方式使用 $array_headers = http_parse_headers($headers); 之后的版本这样使用 $array_headers = http\Header::parse($headers); echo '<pre>'; print_r($array_headers); echo '</pre>';