Yaf_Request_Abstract::getServer

Retrieve a SERVER variable

Description

public mixed Yaf_Request_Abstract::getServer(string $name, mixed $default = ?)

Retrieves a SERVER variable.

Parameters

name
The variable name.
default
The value to return if the variable is not found.

Return Values

The variable value, or default if it is not found.

Examples

Example #1 Yaf_Request_Abstract::getServer example

<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $request = $this->getRequest();

        $host     = $request->getServer("HTTP_HOST");
        $protocol = $request->getServer("SERVER_PROTOCOL", "HTTP/1.1");

        var_dump($host, $protocol);
    }
}
?>

The above example will output something similar to:

string(15) "www.example.com"
string(8) "HTTP/1.1"

See Also

  • Yaf_Request_Abstract::getQuery
  • Yaf_Request_Abstract::getRequest
  • Yaf_Request_Abstract::getPost
  • Yaf_Request_Abstract::getCookie
  • Yaf_Request_Abstract::getFiles
  • Yaf_Request_Abstract::getParam