Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Request_Abstract::getCookieYaf_Request_Abstract::getException>
^Yaf_Request_AbstractLast updated: Mon, 26 Oct 2026

Yaf_Request_Abstract::getEnv

(Yaf >=1.0.0)

Yaf_Request_Abstract::getEnv — Retrieve an ENV variable

Description

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

Retrieves a ENV 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::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);
    }
}
?>

The above example will output something similar to:

string(11) "development"

See Also


<Yaf_Request_Abstract::getCookieYaf_Request_Abstract::getException>
^Yaf_Request_AbstractLast updated: Mon, 26 Oct 2026