PHP 8.6.0 Beta 3 is available for testing

Yaf_Request_Abstract::getServer

(Yaf >=1.0.0)

Yaf_Request_Abstract::getServerRetrieve a SERVER variable

Опис

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

Retrieves a SERVER variable.

Параметри

name

The variable name.

default

The value to return if the variable is not found.

Значення, що повертаються

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

Приклади

Приклад #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);
    }
}
?>

Поданий вище приклад виведе щось схоже на:

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

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top