Webiny\Component\Http\Request\Headers::get PHP Method

get() public method

Get the value from header variables for the given $key.
public get ( string $key, null $value = null ) : string
$key string Key name.
$value null Default value that will be returned if the $key is not found.
return string Value under the defined $key.
    public function get($key, $value = null)
    {
        return $this->headerBag->key($key, $value, true);
    }

Usage Example

コード例 #1
0
ファイル: HeadersTest.php プロジェクト: Webiny/Framework
 public function testGet()
 {
     $_SERVER['HTTP_HOST'] = "localhost";
     $headers = new Headers();
     $this->assertSame("localhost", $headers->get("Host"));
     $this->assertNull($headers->get("doesnt_exist"));
     $this->assertSame("utf8", $headers->get("Encoding", "utf8"));
 }
All Usage Examples Of Webiny\Component\Http\Request\Headers::get