ex.php,Exphp代码走读

if(is_file($classPath)){//文件存在,加载文件

require $classPath;

}else{throw new \Exception($className.‘ does not exists.‘,404);//抛出异常

}

}//$callback 1:NULL,调用函数。2:不为false,绑定函数,3,false,接触绑定

//$value 1,事件存在,为参数,2,事件不存在,为默认值

function event($event,$value=NULL,$callback=NULL){static $_eventStore;if($callback===NULL){if(isset($_eventStore[$event])){foreach($_eventStore[$event] as $function){$value = call_user_func($function,$value);

}

}return $value;

}else{if($callback){$_eventStore[$event][] = $callback;

}else{unset($_eventStore[$event]);

}

}

}function event2($event,$callback=NULL,$params=‘‘){static $_eventMaps;if($callback === NULL){foreach($_eventMaps[$event] as $function){call_user_func_array($function,$params);

}

}else{if(is_callable($callback)){$_eventMaps[$event][] = $callback;

}elseif(!$callback){unset($_eventMaps[$event]);

}else{exit(‘error‘);

}

}

}//$key=NULL,返回$_configStore;

//$key=array,$_configStore = $key;

//isset($_configStore[$key])?$_configStore[$key]:$defaultValue

function config_item($key=NULL,$defaultValue=NULL){static $_configStore;if($key === NULL){return $_configStore;

}if(is_array($key)){$_configStore=$key;return;

}if(!isset($_configStore[$key])){return $defaultValue;

}return $_configStore[$key];

}function config_item2($key=‘‘,$value=‘‘){static $_configMaps=array();if(is_array($key)){$_configMaps = array_merge($_configMaps,$key);

}elseif($key == ‘‘){return $_configMaps;

}elseif($value == ‘‘){return $_configMaps[$key];

}else{$_configMaps[$key] = $value;

}

}//$key===NULL,return $_globalStore

//$value===NULL,return $_globalStore[$key]

//is_array($key)?$_globalStore+=$key:$_globalStore[$key]=$value;

function global_item($key=NULL,$value=NULL){static $_globalStore = array();if($key === NULL){return $_globalStore;

}if($value===NULL){if(isset($_globalStore[$key])){return $_globalStore[$key];

}return NULL;

}else{if(is_array($key)){$_globalStore += $key;

}else{$_globalStore[$key] = $value;

}

}

}function global_item($key=NULL,$value=NULL){static $_globalStore = array();if($key === NULL){return $_globalStore;

}if($value===NULL){if(isset($_globalStore[$key])){return $_globalStore[$key];

}return NULL;

}else{if(is_array($key)){$_globalStore+=$key;

}else{$_globalStore[$key] = $value;

}

}

}//$expire<0,del($key);

//

function cache_item($key,$value=NULL,$expire=864000){iglobal $App;if($expire < 0){return $App->Cache->del($key);

}if($value===NULL){return $App->Cache->get($key,$expire);

}else{$App->Cache->set($key,$value,$expire);

}

}function cache_item2($key,$value,$expire){global $App;if($expire < 0){return $App->Cache->del($key);

}if($value===NULL){return $App->Cache->get($key,$expire);

}else{return $App->Cache->set($key,$value,$expire);

}

}function get_item($key,$itemOption=NULL){if($itemOption === TRUE){if(isset($_GET[$key]))?numf($_GET[$key]):0;

}else{if(isset($_GET[$key]))?(is_string($_GET[$key])?strf($_GET[$key],$itemOption):$_GET[$key]):‘‘;

}

}function post_item($key,$itemOption=NULL){if($itemOption === TRUE){return isset($_POST[$key])?numf($_POST[$key]):0;

}else{return isset($_POST[$key])?(is_string($_POST[$key])?strf($_POST[$key],$itemOption):$_POST[$key]):‘‘;

}

}function cookie_item($key,$value=NULL,$expire=8640000){$key = config_item(‘cookie_pre‘) . $key;if($value === NULL){return isset($_COOKIE[$key])?trim($_COOKIE[$key]):‘‘;

}else{setcookie($key,$value,$expire?global_item(‘timestamp‘)+$expire : 0,‘/‘,config_item(‘cookie_domain‘));

}

}function cookie_item2($key,$value=NULL,$expire=8640000){$key=config_item(‘cookie_pre‘).$key;if($value===NULL){return isset($_COOKIE[$key])?trim($_COOKIE[$key]):‘‘;

}else{setcookie($key,$value,$expire?global_item(‘timestamp‘)+$expire:0,‘/‘,config_item(‘cookie_domain‘));

}

}function getsrv($key){return isset($_SERVER[$key])?$_SERVER[$key]:‘‘;

}function addslashess($var){if(is_array($var)){foreach($var as $key=>$val){$var[$key] = addslashess($val);

}

}else{$var = addslashes($var);

}return $var;

}function safe_filter($var){return addslashess($var);

}function numf($var){return is_numeric($var) ? $var:intval($var);

}function strf($var,$allowableTags=NULL){return trim(($allowableTags)?$var:strip_tags($var,$allowableTags))

}function arrayf($var,$separator=‘,‘){return is_array($var)?$var:explode($separator,$var);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值