PHP 8.6.0 Beta 3 is available for testing

Yaf_Config_Simple::set

(Yaf >=1.0.0)

Yaf_Config_Simple::setSet a configuration value

Description

public function Yaf_Config_Simple::set(string $name, mixed $value): bool

Sets a configuration value. Fails and returns false if the configuration is read-only.

Parameters

name

The configuration key to set.

value

The value to assign.

Return Values

Returns true on success, or false if the configuration is read-only.

Examples

Example #1 Yaf_Config_Simple::set() example

<?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:

bool(true)
production
bool(false)
development

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top