Dutch PHP Conference 2027

Yaf_Config_Ini::offsetGet

(Yaf >=1.0.0)

Yaf_Config_Ini::offsetGetGet a value (ArrayAccess)

Beschreibung

public function Yaf_Config_Ini::offsetGet(mixed $name): mixed

Retrieves a configuration value by key. This method is an alias of Yaf_Config_Ini::get() and is called when array syntax is used to read a configuration object.

Parameter-Liste

name

The configuration key to retrieve.

Rückgabewerte

The value associated with name, or null if the key does not exist.

Beispiele

Beispiel #1 Yaf_Config_Ini::offsetGet() example

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

echo $config['application.name'], "\n"; // dot notation, as in get()
echo $config['database']['host'], "\n"; // nested access
var_dump($config['cache.enable']);      // missing key
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

MyApp
localhost
NULL

Siehe auch

add a note

User Contributed Notes

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