Heim >php教程 >PHP源码 >读写数组类型配置文件

读写数组类型配置文件

PHP中文网
PHP中文网Original
2016-05-25 17:00:291394Durchsuche


// 写入配置文件的变量
public static function rewriteConfig($key, $value) {
	$path = app_path() . '/storage/Config.php';
	$contents = file_get_contents($path);
	$contents = str_replace(self::loadConfig($key), $value, $contents);
	file_put_contents($path, $contents);
}

// 读取配置文件的变量
public static function loadConfig($key) {
	$Config = require(app_path() . '/storage/Config.php');
	return $Congig[$key];
}

                   

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn