php8.5
Home/ Manual/ yaf / yaf_config_abstract/ Yaf_Config_Abstract::set

Yaf_Config_Abstract::set

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Set a configuration value

Description

Yaf_Config_Abstract::set(string $name, mixed $value): bool

Sets a configuration value. This method is abstract and must be implemented by subclasses. Read-only configurations will reject modifications.

Parameters

name

The configuration key to set.

value

The value to assign.

Return Values

Returns true on success, or false on failure (e.g. when the configuration is read-only).

Examples

Yaf_Config_Abstract::set example

php
<?php
$config = new Yaf_Config_Simple(['env' => 'development']);
var_dump($config->set('env', 'production'));
echo $config->env, "\n";

// Read-only implementations reject the modification
$ini = new Yaf_Config_Ini('/etc/myapp/application.ini', 'common');
var_dump($ini->set('env', 'production'));
?>

The above example will output something similar to:

output
bool(true)
production
bool(false)

See Also

  • Yaf_Config_Abstract::get
  • Yaf_Config_Abstract::readonly

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