note 23408 added to function.parse-ini-file
| From: | cyberkill3r at hotmail dot com | Date: | Wed, 17 Jul 2002 17:41:46 +0000 |
| Subject: | note 23408 added to function.parse-ini-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33219@lists.php.net to get a copy of this message | ||
If you want to edit a ini file using php try this function:
<?php
//Edit ini files
function edit_ini($ini_file, $what, $replace){
$fp = fopen($ini_file, "r");//open file
$contents = fread($fp, filesize($ini_file));
fclose($fp);
$new_contents = ereg_replace($what, $replace, $contents);
$fp = fopen($ini_file, "w");
fwrite($fp, $new_contents);
fclose($fp);
echo "Ini file saved";
}
?>
usage:
edit_ini(ini_file, replace configuration, replace with);
//example: This is replace SMTP = localhost to SMTP = 127.0.0.1 in php.ini
edit_ini("php.ini", "SMTP = localhost", "SMTP = 127.0.0.1");
++hope to help
++ckill3r
--
http://www.php.net/manual/en/function.parse-ini-file.php
http://master.php.net/manage/user-notes.php?action=edit+23408
http://master.php.net/manage/user-notes.php?action=delete+23408
http://master.php.net/manage/user-notes.php?action=reject+23408