$("p").css("color").addClass("selected");
$str = 'abs123 '; echo strlen(trim($str));
$str = 'abs123 '; echo $str->trim()->strlen();
/**
* 对象链式操作
* 2015-04-24
*/
class BaseChainObject{
/**
* 追溯数据,用来进行调试
* @var array
*/
private $_trace_data = array();
/**
* 保存可用方法列表
* @param array
*/
protected $_methods = array();
/**
* 处理的数据
* @param null
*/
public $data;
function __construct($data){
$this->data = $data;
$this->_trace_data['__construct'] = $data;
return $this->data;
}
function __toString(){
return (String)$this->data;
}
function __call($name,$args){
try{
$this->vaild_func($name);
}catch(Exception $e){
echo $e->getMessage();
exit();
}
if (!$args) {
$args = $this->data;
$this->data = call_user_func($name,$args);
}else{
$this->data = call_user_func_array($name,$args);
}
$this->_trace_data[$name] = $this->data;
return $this;
}
/**
* 判断方法是否存在
* @param string
*/
private function vaild_func($fn){
if(!in_array($fn, $this->_methods)){
throw new Exception("unvaild method");
}
}
public function trace(){
var_dump($this->_trace_data);
}
}
class String extends BaseChainObject{
protected $_methods = array('trim','strlen');
}
$str = new String('ab rewqc ');
echo $str->trim()->strlen();
$str->trace();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有