PHP 8.3.4 Released!

ini_restore

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

ini_restoreRestablece el valor de una opción de configuración

Descripción

ini_restore(string $varname): void

Restaura una opción de configuración dado su valor original.

Parámetros

varname

El nombre de la opción de configuración.

Valores devueltos

No devuelve ningún valor.

Ejemplos

Ejemplo #1 ini_restore() ejemplo

<?php
$setting
= 'y2k_compliance';

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

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

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

El resultado del ejemplo sería:

Valor actual 'y2k_compliance': 1
Nuevo valor 'y2k_compliance': 0
Valor original 'y2k_compliance': 1

Ver también

  • ini_get() - Devuelve el valor de una directiva de configuración
  • ini_get_all() - Obtiene todas las opciones de configuración
  • ini_set() - Establece el valor de una directiva de configuración

add a note

User Contributed Notes 1 note

up
7
Anonymous
8 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