php8.5
Home/ Manual/ yaf / yaf_config_ini/ Yaf_Config_Ini::offsetSet

Yaf_Config_Ini::offsetSet

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Set a configuration value (ArrayAccess)

Description

Yaf_Config_Ini::offsetSet(mixed $name, mixed $value): void

Attempts to set a configuration value using array syntax. This method is an alias of Yaf_Config_Ini::set. Since Yaf_Config_Ini is always read-only, it always fails and emits a warning.

Parameters

name

The configuration key to set.

value

The value to assign.

Return Values

No value is returned. A warning is emitted, because Yaf_Config_Ini is read-only.

Examples

Yaf_Config_Ini::offsetSet example

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

// Yaf_Config_Ini is read-only: a warning is emitted and the value is kept
$config['database.host'] = '192.0.2.10';

echo $config['database.host'], "\n";
?>

The above example will output something similar to:

output
localhost

See Also

  • Yaf_Config_Ini::set
  • Yaf_Config_Ini::offsetGet
  • Yaf_Config_Ini::readonly

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