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_Config_AbstractYaf_Config_Abstract::readonly>
^Yaf_Config_AbstractLast updated: Mon, 26 Oct 2026

Yaf_Config_Abstract::get

(Yaf >=1.0.0)

Yaf_Config_Abstract::get — Retrieve a configuration value

Description

public function Yaf_Config_Abstract::get(string $name = NULL): mixed

Retrieves a configuration value by name. If name is omitted or null, the configuration object itself is returned, which can be used to iterate over all values.

Parameters

name

The configuration key. Dot notation (e.g. database.host) may be used to access nested values.

Return Values

The value associated with name. Array values are wrapped in a Yaf_Config_Abstract object. Returns null if the key does not exist, or the configuration object itself when name is null.

Examples

Example #1 Yaf_Config_Abstract::get() example

<?php
/**
 * Assume /etc/myapp/application.ini contains:
 * [common]
 * database.host = "localhost"
 * database.port = 3306
 */
$config = new Yaf_Config_Ini('/etc/myapp/application.ini', 'common');
echo $config->get('database.host'), "\n";

$simple = new Yaf_Config_Simple([
    'database' => ['host' => '127.0.0.1'],
]);

// Array values are exposed as Yaf_Config_Abstract instances
echo $simple->get('database')->host, "\n";

var_dump($config->get('missing.key'));
?>

The above example will output something similar to:

localhost
127.0.0.1
NULL

See Also


<Yaf_Config_AbstractYaf_Config_Abstract::readonly>
^Yaf_Config_AbstractLast updated: Mon, 26 Oct 2026