get() 공개 메소드

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.
리턴 string Value under the defined $key.
예제 #1
0
 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"));
 }
예제 #2
0
 /**
  * Get a value from HTTP Headers
  * If key doesn't not exist, $value will be returned and assigned under that key.
  *
  * @param string $key   Key for which you wish to get the value.
  * @param mixed  $value Default value that will be returned if $key doesn't exist.
  *
  * @return mixed Value of the given $key.
  */
 public function header($key = null, $value = null)
 {
     return $this->isNull($key) ? $this->headers->getAll() : $this->headers->get($key, $value);
 }