Yaf_Request_Abstract::getEnv
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Retrieve an ENV variable
Description
Yaf_Request_Abstract::getEnv(string $name, [mixed $default]): mixed
Retrieves a ENV 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::getEnv example
php
<?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:
output
string(11) "development"See Also
Yaf_Request_Abstract::getQueryYaf_Request_Abstract::getRequestYaf_Request_Abstract::getPostYaf_Request_Abstract::getCookieYaf_Request_Abstract::getFilesYaf_Request_Abstract::getParam