ini_restore

(PHP 4, PHP 5, PHP 7, PHP 8)

ini_restoreRestaura o valor de uma opção de configuração

Descrição

ini_restore(string $option): void

Restaura uma determinada opção de configuração ao seu valor original.

Parâmetros

option

O nome da opção de configuração.

Valor Retornado

Nenhum valor é retornado.

Exemplos

Exemplo #1 Exemplo de ini_restore()

<?php
$setting
= 'html_errors';

echo
'Valor atual para \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;

ini_set($setting, ini_get($setting) ? 0 : 1);
echo
'Novo valor para \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;

ini_restore($setting);
echo
'Valor original para \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;
?>

O exemplo acima produzirá:

Valor atual para 'html_errors': 1
Novo valor para 'html_errors': 0
Valor original para 'html_errors': 1

Veja Também

  • ini_get() - Obtém o valor de uma opção de configuração
  • ini_get_all() - Obtém todas as opções de configuração
  • ini_set() - Define o valor de uma opção de configuração

adicione uma nota

Notas Enviadas por Usuários (em inglês) 1 note

up
4
Anonymous
9 years ago
If like me you thought ini_restore() would restore to the most recent setting rather than the startup value, you could use this.<?php/** * Executes a function using a custom PHP configuration. *  * @param array $settings A map<ini setting name, ini setting value>. * @param callable $doThis The code to execute using the given settings. * @return mixed Returns the value returned by the given callable. */function ini_using_do(array $settings, callable $doThis){    foreach($settings as $name => $value){        $previousSettings[$name] = ini_set($name, $value);    }    $returnValue = $doThis();    if(isset($previousSettings)){        foreach($previousSettings as $name => $value){            ini_set($name, $value);        }    }    return $returnValue;}?>
To Top