thinkphp自定义标签的问题,标签内显示查询后的数据 另外模仿写了input标签和compare标签,都可以使用,因为不涉及数据库,就db那个标签在html上要怎么显示,我要输入查询的结果 求大神赐教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php class TagLibTest extends TagLib{ protected $tags=array( 'input'=>array('attr'=>'type,name,id,value','close'=>0), 'compare'=>array('attr'=>'name,value,type','alias'=>'gt,lt','close'=>1), 'db'=>array('attr'=>'table,order,limit,id,result','close'=>1,'level'=>3), ); public function _input($attr,$content) { $tag = $this->parseXmlAttr($attr,'input'); //$name = $tag['name']; //$id = $tag['id']; //$type = $tag['type']; $value = $this->autoBuildVar($tag['value']); $str = '<input type="'.$type.'" id="'.$id.'"name="'.$name.'" value="'.$value.'" />'; return $str; } public function _compare($attr,$content,$type){ //exit('123'); $tag = $this->parseXmlAttr($attr,'compare'); $type=$tag['type']?$tag['type']:$type; $type=($type=="gt"?">":"<"); $str=$tag['name'].$type.$tag['value']; //var_dump($str);exit; return $str; } public function _gt($attr,$content){ //exit('123'); return $this->_compare($attr,$content,"gt"); } public function _lt($attr,$content){ return $this->_compare($attr,$content,"lt"); } public function _db($attr,$content){ $tag = $this->parseXmlAttr($attr,'db'); $table=$tag['table']?$tag['table']:$table; $table=ucfirst($table); $order=$tag['order']; $limit=$tag['limit']; $id=$tag['id']; $model=M($table); $result=$model->order($order)->limit($limit)->select(); //echo $model->getLastSql();exit; //dump($result);exit; //foreach($result as $id){ //$content; //} return $result; } }?> <taglib name='Test' /><h3>测试compare</h3><test:gt name="5" value="3"></test:gt><test:lt name="3" value="5"></test:lt><test:compare name="5" value="3" type="gt"></test:compare><h4>测试db</h4><test:db table="Exhibit2" id="vo" order="id" limit="3" > 111</test:db>已经引用了标签 但是 在html测试db中怎么获取TagLibTest中'db'标签_db函数返回的$result的结果? 怎么截取域名中间的内容 纠结了一天的转pdf问题,还是不行 请懂Php和C#的朋友看看这两段代码 求一个简单的正则将这个{....} 替换为空~~ PHP 国际化 获取语言类型 广州首饰公司招PHP程序员 smarty 模板编辑器 请问一个很菜的问题,提交后如何判断一条记录是否存在? 字符串操作,如果我要让“www.csdn.net”中的“csdn”用红色显示,怎么做?此功能用在,类似goole搜索的关键字红色显示。 谁熟练 PHP? 安装easyphp之前需要安装mysql吗? 关于drupal
class TagLibTest extends TagLib{
protected $tags=array(
'input'=>array('attr'=>'type,name,id,value','close'=>0),
'compare'=>array('attr'=>'name,value,type','alias'=>'gt,lt','close'=>1),
'db'=>array('attr'=>'table,order,limit,id,result','close'=>1,'level'=>3),
);
public function _input($attr,$content) {
$tag = $this->parseXmlAttr($attr,'input');
//$name = $tag['name'];
//$id = $tag['id'];
//$type = $tag['type'];
$value = $this->autoBuildVar($tag['value']);
$str = '<input type="'.$type.'" id="'.$id.'"name="'.$name.'" value="'.$value.'" />';
return $str;
}
public function _compare($attr,$content,$type){
//exit('123');
$tag = $this->parseXmlAttr($attr,'compare');
$type=$tag['type']?$tag['type']:$type;
$type=($type=="gt"?">":"<");
$str=$tag['name'].$type.$tag['value'];
//var_dump($str);exit;
return $str;
}
public function _gt($attr,$content){
//exit('123');
return $this->_compare($attr,$content,"gt");
}
public function _lt($attr,$content){
return $this->_compare($attr,$content,"lt");
}
public function _db($attr,$content){
$tag = $this->parseXmlAttr($attr,'db');
$table=$tag['table']?$tag['table']:$table;
$table=ucfirst($table);
$order=$tag['order'];
$limit=$tag['limit'];
$id=$tag['id'];
$model=M($table);
$result=$model->order($order)->limit($limit)->select();
//echo $model->getLastSql();exit;
//dump($result);exit;
//foreach($result as $id){
//$content;
//}
return $result;
}
}
?>
<test:gt name="5" value="3">
</test:gt>
<test:lt name="3" value="5">
</test:lt>
<test:compare name="5" value="3" type="gt">
</test:compare><h4>测试db</h4>
<test:db table="Exhibit2" id="vo" order="id" limit="3" >
111
</test:db>已经引用了标签 但是 在html测试db中怎么获取TagLibTest中'db'标签_db函数返回的$result的结果?