PHP Conference Ehime 2026

Yaf_Config_Simple::offsetUnset

(Yaf >=1.0.0)

Yaf_Config_Simple::offsetUnsetRemove a key (ArrayAccess)

Beschreibung

public function Yaf_Config_Simple::offsetUnset(mixed $name): void

Removes a configuration entry by key. This method is called when unset() is used with array syntax on a configuration object.

Parameter-Liste

name

The configuration key to remove.

Rückgabewerte

No value is returned. A warning is emitted if the configuration is read-only.

Beispiele

Beispiel #1 Yaf_Config_Simple::offsetUnset() example

<?php
$config = new Yaf_Config_Simple([
    'cache' => ['enable' => true],
    'env'   => 'development',
]);

unset($config['cache']);
var_dump(isset($config['cache']));

// Read-only configurations cannot be modified: a warning is emitted
$frozen = new Yaf_Config_Simple(['env' => 'development'], true);
unset($frozen['env']);
var_dump(isset($frozen['env']));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

bool(false)
bool(true)

Siehe auch

add a note

User Contributed Notes

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