Yaf_Config_Simple::set
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Set a configuration value
Description
Yaf_Config_Simple::set(string $name, mixed $value): bool
Sets a configuration value. Fails and returns false if the configuration is read-only.
Parameters
nameThe configuration key to set.
valueThe value to assign.
Return Values
Returns true on success, or false if the configuration is read-only.
Examples
Yaf_Config_Simple::set example
php
<?php
$config = new Yaf_Config_Simple(['env' => 'development']);
var_dump($config->set('env', 'production'));
echo $config->env, "\n";
// Read-only configurations reject the modification
$frozen = new Yaf_Config_Simple(['env' => 'development'], true);
var_dump($frozen->set('env', 'production'));
echo $frozen->env, "\n";
?>The above example will output something similar to:
output
bool(true)
production
bool(false)
developmentSee Also
Yaf_Config_Simple::getYaf_Config_Simple::readonly