getHeader() публичный Метод

Get a response header
public getHeader ( string $name ) : mixed
$name string
Результат mixed
Пример #1
0
 public function testHeadersAndBody()
 {
     $c = new Curl('http://www.popphp.org/version', array(CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true));
     $c->execute();
     $this->assertEquals('text/plain', $c->getHeader('Content-Type'));
     $this->assertGreaterThan(1, count($c->getHeaders()));
     $this->assertContains('HTTP', $c->getRawHeader());
     $this->assertEquals('1.7.0', $c->getBody());
     $this->assertEquals('200', $c->getCode());
     $this->assertEquals('1.1', $c->getHttpVersion());
     $this->assertEquals('OK', $c->getMessage());
 }
Пример #2
0
<?php

require_once '../../bootstrap.php';
use Pop\Curl\Curl;
try {
    $curl = new Curl('http://www.popphp.org/license');
    $curl->execute();
    header('Content-Type: ' . $curl->getHeader('Content-Type'));
    echo $curl->getBody();
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL . PHP_EOL;
}