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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:35:36
Original
1625 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
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template