Dutch PHP Conference 2027

Yaf_Config_Simple::get

(Yaf >=1.0.0)

Yaf_Config_Simple::getRetrieve a configuration value

Beschreibung

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

Retrieves a configuration value by name. If name is omitted or null, the configuration object itself is returned.

Parameter-Liste

name

The configuration key to retrieve.

Rückgabewerte

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

Beispiele

Beispiel #1 Yaf_Config_Simple::get() example

<?php
$config = new Yaf_Config_Simple([
    'application' => ['name' => 'MyApp'],
    'database'    => ['host' => 'localhost'],
]);

// Array values are wrapped in a Yaf_Config_Simple object
echo $config->get('database')->host, "\n";
echo $config->get('application')->name, "\n";
var_dump($config->get('missing'));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

localhost
MyApp
NULL

Siehe auch

add a note

User Contributed Notes

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