我将 cURL 与 zend 框架一起使用,它给了我标题和站点内容。
我在另一个类中使用此输出,我想从 curl 输出中提取标题以查看语言是否为 ser(内容语言)。
输出具有受保护的类,例如响应和标头,我尝试设置类标头和响应以尝试通过此获取标头值,但它没有给我任何结果。
(卷曲输出 => $this-> 内容)
class Zend\Http\Response#258 (7) { protected $recommendedReasonPhrases => array(57) { [100] => string(8) "Continue"
[101] => string(19) "交换协议" [102] => string(10) "处理" [200] => string(2) "OK" [201] => string(7) "创建" [ 202] => string(8) "已接受" [203] => string(29) "非权威信息" [204] => string(10) "无内容" [205] => string(13) "重置内容”[206] => 字符串(15)“部分内容”[207] => 字符串(12)“多状态”[208] => 字符串(16)“已报告”[300] => 字符串(16 ) "多项选择" [301] => string(17) "永久移动" [302] => string(5) "找到" [303] => string(9) "查看其他" [304] => string( 12)“未修改”[305] => 字符串(9)“使用代理”[306] => 字符串(12)“切换代理”[307] => 字符串(18)“临时重定向”[400] => 字符串(11)“错误请求”[401] => 字符串(12)“未授权”[402] => 字符串(16) “需要付款”[403] => 字符串(9)“禁止”[404] => 字符串(9)“未找到”[405] => 字符串(18)“方法不允许”[406] => 字符串( 14)“不可接受”[407] => 字符串(29)“需要代理身份验证”[408] => 字符串(16)“请求超时”[409] => 字符串(8)“冲突”[410] => string(4) "Gone" [411] => string(15) "Length required" [412] => string(19) "Precondition Failed" [413] => string(24) "Request Entity Too Large" [414] => 字符串(21)“请求 URI 太大”[415] => 字符串(22)“不支持的媒体类型”[416] => 字符串(31)“请求的范围不可满足”[417] => 字符串(18)“预期失败”[418] => 字符串(12 ) “我是茶壶”[422] => 字符串(20)“无法处理的实体”[423] => 字符串(6)“锁定”[424] => 字符串(17)“依赖失败”[425] = > 字符串(20)“无序集合”[426] => 字符串(16)“需要升级”[428] => 字符串(21)“需要先决条件”[429] => 字符串(17)“请求太多”[ 431] => 字符串(31)“请求标头字段太大”[500] => 字符串(21)“内部服务器错误”[501] => 字符串(15)“未实现”[502] => 字符串(11 ) “坏网关” [503] =>字符串(19)“服务不可用”[504] => 字符串(16)“网关超时”[505] => 字符串(26)“不支持 HTTP 版本”[506] => 字符串(23)“变体也协商" [507] => string(20) "Insufficient Storage" [508] => string(13) "Loop Detected" [511] => string(31) "Network Authentication required" } protected $statusCode => int( 200) protected $reasonPhrase => string(2) "OK" protected $version => string(3) "1.1" protected $headers => class Zend\Http\Headers#257 (3) { protected $pluginClassLoader => NULL protected $headersKeys => array(15) { [0] => string(4) "date" [1] => string(6) "server" [2] => string(10) "xpoweredby" [3] =>字符串(12)“xdrupalcache”[4] => string(7) "expires" [5] => string(12) "lastmodified" [6] => string(12) "cachecontrol" [7] => string(4) "etag" [8 ] => string(15) "contentlanguage" [9] => string(10) "xgenerator" [10] => string(4) "vary" [11] => string(15) "contentencoding" [12] = > string(13) "contentlength" [13] => string(10) "connection" [14] => string(11) "contenttype" } protected $headers => array(15) { [0] => array( 2) { 'name' => string(4) "Date" 'line' => string(35) "Date: Tue, 26 Feb 2013 09:57:42 GMT" } [1] => array(2) { 'name' => string(6) "Server" 'line' => string(30) "Server: Apache/2.2.14 (Ubuntu)" } [2] =>array(2) { 'name' => string(12) "X-Powered-By" 'line' => string(35) "X-Powered-By: PHP/5.3.2-1ubuntu4.18" } [3 ] => array(2) { 'name' => string(14) "X-Drupal-Cache" 'line' => string(20) "X-Drupal-Cache: MISS" } [4] => array( 2) { 'name' => string(7) "Expires" 'line' => string(38) "Expires: Sun, 19 Nov 1978 05:00:00 GMT" } [5] => array(2) { 'name' => string(13) "Last-Modified" 'line' => string(46) "Last-Modified: Tue, 26 Feb 2013 09:57:42 +0000" } [6] => array(2 ) { 'name' => string(13) "Cache-Control" 'line' => string(32) "Cache-Control: public, max-age=0" } [7] => array(2) { '名字' =>string(4) "ETag" 'line' => string(20) "ETag: "1361872662-1"" } [8] => array(2) { 'name' => string(16) "Content-Language" 'line' => string(20) "Content-Language: ru" } [9] => array(2) { 'name' => string(11) "X-Generator" 'line' => string(41) “X 生成器:Drupal 7 (http://drupal.org )" } [10] => array(2) { 'name' => string(4) "Vary" 'line' => string(28) "Vary: Cookie,Accept-Encoding" } [11] => array(2) { 'name' => string(16) "Content-Encoding" 'line' => string(22) "Content-Encoding: gzip" } [12] => array(2 ) { 'name' => string(14) "Content-Length" 'line' => string(20) "Content-Length: 7139" } [13] => array(2) { 'name' => string( 10) "连接" 'line' => string(17) "Connection: close" } [14] => array(2) { 'name' => string(12) "Content-Type" 'line' => string (38)“内容类型:text/html;charset=utf-8" } } } 受保护的 $metadata =>
(代码)
$response = new Response();
$response->getHeaders($this->content);
$headers = new Headers();
var_dump($headers->get('Content-Language'));
(生成)
bool(false)
($response->getHeaders 的 var_dump)
类 Zend\Http\Headers#259 (3) { protected $pluginClassLoader => NULL protected $headersKeys => array(0) { } protected $headers => array(0) { } }
提前致谢,
缺口