Prado\Web\THttpRequest::remove PHP Method

remove() public method

Removes an item from the request by its key.
public remove ( $key ) : mixed
return mixed the removed value, null if no such key exists.
    public function remove($key)
    {
        if (isset($this->_items[$key]) || array_key_exists($key, $this->_items)) {
            $value = $this->_items[$key];
            unset($this->_items[$key]);
            return $value;
        } else {
            return null;
        }
    }

Usage Example

Exemplo n.º 1
0
 public function testRemove()
 {
     $request = new THttpRequest();
     $request->init(null);
     // Simulate a request with just a service
     $_GET['page'] = 'Home';
     $request->resolveRequest(array('page'));
     // Remove an unknow key
     self::assertNull($request->remove('param1', 'value1'));
     // Remove a key
     self::assertEquals('Home', $request->remove('page'));
 }