ini_restore

(PHP 4, PHP 5, PHP 7)

ini_restoreRestores the value of a configuration option

Descrierea

ini_restore ( string $option ) : void

Restores a given configuration option to its original value.

Parametri

option

The configuration option name.

Valorile întoarse

Nu este întoarsă nici o valoare.

Exemple

Example #1 ini_restore() example

<?php
$setting 
'y2k_compliance';

echo 
'Current value for \'' $setting '\': ' ini_get($setting), PHP_EOL;

ini_set($settingini_get($setting) ? 1);
echo 
'New value for \'' $setting '\': ' ini_get($setting), PHP_EOL;

ini_restore($setting);
echo 
'Original value for \'' $setting '\': ' ini_get($setting), PHP_EOL;
?>

Exemplul de mai sus va afișa:

Current value for 'y2k_compliance': 1
New value for 'y2k_compliance': 0
Original value for 'y2k_compliance': 1

A se vedea și

add a note add a note

User Contributed Notes 1 note

up
4
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