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

读写数组类型配置文件

PHP中文网
Release: 2016-05-25 17:00:29
Original
1389 people have browsed it


// 写入配置文件的变量
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];
}
Copy after login

                   

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template