php8.5
Home/ Manual/ yaf / yaf_config_simple/ Yaf_Config_Simple::offsetUnset

Yaf_Config_Simple::offsetUnset

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Remove a key (ArrayAccess)

Description

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.

Parameters

name

The configuration key to remove.

Return Values

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

Examples

Yaf_Config_Simple::offsetUnset example

php
<?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']));
?>

The above example will output something similar to:

output
bool(false)
bool(true)

See Also

  • Yaf_Config_Simple::offsetGet
  • Yaf_Config_Simple::offsetSet

Source: reference/yaf/yaf_config_simple/offsetunset.xml · from the official PHP manual (php/doc-en)