Yaf_Config_Simple::offsetSet

(Yaf >=1.0.0)

Yaf_Config_Simple::offsetSetSet a configuration value (ArrayAccess)

Description

public function Yaf_Config_Simple::offsetSet(mixed $name, mixed $value): void

Sets a configuration value using array syntax. This method is an alias of Yaf_Config_Simple::set(). The assignment fails silently if the configuration is read-only.

Parameters

name

The configuration key to set.

value

The value to assign.

Return Values

No value is returned. The assignment fails if the configuration is read-only.

Examples

Example #1 Yaf_Config_Simple::offsetSet() example

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

// Writable by default
$config['env'] = 'production';
$config['cache'] = ['enable' => true];
echo $config['env'], "\n";
var_dump($config['cache']['enable']);

// Assignments to a read-only configuration fail silently
$frozen = new Yaf_Config_Simple(['env' => 'development'], true);
$frozen['env'] = 'production';
echo $frozen['env'], "\n";
?>

The above example will output something similar to:

production
bool(true)
development

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.