日期:2014-05-17 浏览次数:20498 次
function C($name=null,$value=null){ static $config=array();//配置项 if(is_null($name)){ return $config; } if(!is_null($name)){ if(is_string($name)){ $name = strtolower($name); if(is_null($value)){ return isset($config[$name])?$config[$name]:false; } $config[$name]=$value; }elseif(is_array($name)){ $name = array_change_key_case($name,CASE_LOWER); $config = array_merge($config,$name); } } }
c("hello", "I say hello"); //一次赋值 c(array("a", "b")); //二次赋值 var_dump( c()); array(3) { ["hello"]=> string(11) "I say hello" [0]=> string(1) "a" [1]=> string(1) "b" }