PHPUnit-调用未定义的函数http_parse_headers()错误 [英] PHPUnit - Call to undefined function http_parse_headers() error

查看:118
本文介绍了PHPUnit-调用未定义的函数http_parse_headers()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码

protected function parse($header) { $headerArr = http_parse_headers($header); foreach ($headerArr as $key => $value) { echo $key.'=>'.$value; } }

protected function parse($header) { $headerArr = http_parse_headers($header); foreach ($headerArr as $key => $value) { echo $key.'=>'.$value; } }

其中$ header是http标头.此代码在symfony2项目的PHP类中.我可以在浏览器中执行它,并获得预期的结果,像这样解析后的标头的键和值

where $header is a http header. This code is in a PHP Class in a symfony2 project. I can execute it in a browser an get the expected results the keys and values of the parsed header like this

  • 响应码=> 200
  • 响应状态=>确定
  • Date => Sun,2014年7月13日格林尼治标准时间
  • Server => Apache/2.4.7(Ubuntu)
  • 最后修改=>星期三,2014年3月26日格林尼治标准时间
  • Etag => 502-4f58a50290480
  • 接受范围=>字节
  • Content-Length => 1282
  • Content-Disposition =>附件; filename = mvc.zip
  • 保持活动=>超时= 5,最大= 100
  • Connection =>保持活动
  • Content-Type =>应用程序/邮政编码
  • Response Code=>200
  • Response Status=>OK
  • Date=>Sun, 13 Jul 2014 21:39:51 GMT
  • Server=>Apache/2.4.7 (Ubuntu)
  • Last-Modified=>Wed, 26 Mar 2014 22:51:46 GMT
  • Etag=>502-4f58a50290480
  • Accept-Ranges=>bytes
  • Content-Length=>1282
  • Content-Disposition=>attachment; filename= mvc.zip
  • Keep-Alive=>timeout=5, max=100
  • Connection=>Keep-Alive
  • Content-Type=>application/zip

问题是,当我尝试为函数parse()运行单元测试时,PHPUnit找不到抛出"PHP致命错误:调用未定义函数http_parse_headers()

The problem is when i try to run a unit test for the function parse(), the PHPUnit can't find the http_parse_headers() function an throws "PHP Fatal error: Call to undefined function http_parse_headers()

这怎么可能? 我该如何解决?

How is this posible? How can I fix it?

推荐答案

对PHP手册的快速搜索显示http_parse_headers是pecl扩展的一部分:PECL pecl_http> = 0.10.0

A quick search of the PHP manual shows that http_parse_headers is part of a pecl extension: PECL pecl_http >= 0.10.0

您的服务器和命令行php版本必须不同. php手册可以解决,但希望您可以更新命令行版本.

Your server and your command line php versions must be different. The php manual has a work around but hopefully you can just update your command line version.

这篇关于PHPUnit-调用未定义的函数http_parse_headers()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆