Yaf_Request_Abstract::getServer
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Retrieve a SERVER variable
Description
Yaf_Request_Abstract::getServer(string $name, [mixed $default]): mixed
Retrieves a SERVER variable.
Parameters
nameThe variable name.
defaultThe value to return if the variable is not found.
Return Values
The variable value, or default if it is not found.
Examples
Yaf_Request_Abstract::getServer example
php
<?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:
output
string(15) "www.example.com"
string(8) "HTTP/1.1"See Also
Yaf_Request_Abstract::getQueryYaf_Request_Abstract::getRequestYaf_Request_Abstract::getPostYaf_Request_Abstract::getCookieYaf_Request_Abstract::getFilesYaf_Request_Abstract::getParam