Yaf_Request_Abstract::getEnv
PHP Manual
PHP Manual»Yaf_Request_Abstract»Yaf_Request_Abstract::getEnv

Yaf_Request_Abstract::getEnv

(Yaf >=1.0.0)

Yaf_Request_Abstract::getEnv — Retrieve an ENV variable

Beschreibung

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

Retrieves a ENV variable.

Parameter-Liste

name

The variable name.

default

The value to return if the variable is not found.

Rückgabewerte

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

Beispiele

Beispiel #1 Yaf_Request_Abstract::getEnv() example

<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // Assuming the process runs with APPLICATION_ENV=development
        $env = $this->getRequest()->getEnv("APPLICATION_ENV", "production");

        var_dump($env);
    }
}
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

string(11) "development"

Siehe auch

To Top