Home > php教程 > php手册 > PHP获取和设置配置参数函数

PHP获取和设置配置参数函数

WBOY
Release: 2016-06-06 19:35:36
Original
1608 people have browsed it

无详细内容 无 /** *获取和设置配置参数 * @param string | array $name 配置变量 *@param mixed $value 配置值 *@param mixed $default 默认值 *@return mixed */function C($name = null, $value = null, $default = null) {static $_config = array();//

/**
 *	获取和设置配置参数 
 * 	@param string | array $name 配置变量
 *	@param mixed $value 配置值
 *	@param mixed $default 默认值
 *	@return mixed
 */
function C($name = null, $value = null, $default = null) {
	static $_config = array();
	// 无参数获取 
	if (empty($name)) {
		return $_config;
	}

	//  优先执行设置获取或赋值
	if (is_string($name)) {
		if (false !== strpos($name, '.')) {
			$name = strtoupper($name);
			if (is_null($value)) {
				return isset($_config[$name]) ? $_config[$name] : $default;
			}
			$_config[$name] = $value;

			return ;
		}
	}

	// 数组配量设置
	if (is_array($name)) {
		$_config = array_merge($_config, array_change_key_case($name, CASE_UPPER));
		return ;
	}

	return null;	// 避免非法参数
}
Copy after login
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template