note 118625 added to function.ini-restore
| From: | Anonymous | Date: | Mon, 11 Jan 2016 14:08:30 +0000 |
| Subject: | note 118625 added to function.ini-restore | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204639@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 87.7.137.103
----
Manual Page -- http://php.net/manual/en/function.ini-restore.php
Edit -- https://master.php.net/note/edit/118625
Del: integrated -- https://master.php.net/note/delete/118625/integrated
Del: useless -- https://master.php.net/note/delete/118625/useless
Del: bad code -- https://master.php.net/note/delete/118625/bad+code
Del: spam -- https://master.php.net/note/delete/118625/spam
Del: non-english -- https://master.php.net/note/delete/118625/non-english
Del: in docs -- https://master.php.net/note/delete/118625/in+docs
Del: other reasons-- https://master.php.net/note/delete/118625
Reject -- https://master.php.net/note/reject/118625
Search -- https://master.php.net/manage/user-notes.php