get() public method

Get the value from GET 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.
Beispiel #1
0
 public function testGet()
 {
     $_GET = ["name" => "jack"];
     $query = new Query();
     $this->assertSame("jack", $query->get("name"));
     $this->assertNull($query->get("NON_EXISTING"));
     $this->assertSame("doe", $query->get("NON_EXISTING_2", "doe"));
 }
Beispiel #2
0
 /**
  * Get a value from $_GET param for the given $key.
  * 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 query($key = null, $value = null)
 {
     return $this->isNull($key) ? $this->query->getAll() : $this->query->get($key, $value);
 }