近期在看YIIpublic $template='{view} {update} {delete}';
以上这种写法,如何单独输出{view},{update}呢
同时以下代码片段还会报错foreach(array('view','update','delete') as $id)
{
$button=array(
'label'=>$this->{$id.'ButtonLabel'},
'url'=>$this->{$id.'ButtonUrl'},
'imageUrl'=>$this->{$id.'ButtonImageUrl'},
'options'=>$this->{$id.'ButtonOptions'},
);
if(isset($this->buttons[$id]))
$this->buttons[$id]=array_merge($button,$this->buttons[$id]);
else
$this->buttons[$id]=$button;
}报错提示:Fatal error: Using $this when not in object context in D:\Wamp\Apache\htdocs\1.01\this.php on line 9
以上这种写法,如何单独输出{view},{update}呢
同时以下代码片段还会报错foreach(array('view','update','delete') as $id)
{
$button=array(
'label'=>$this->{$id.'ButtonLabel'},
'url'=>$this->{$id.'ButtonUrl'},
'imageUrl'=>$this->{$id.'ButtonImageUrl'},
'options'=>$this->{$id.'ButtonOptions'},
);
if(isset($this->buttons[$id]))
$this->buttons[$id]=array_merge($button,$this->buttons[$id]);
else
$this->buttons[$id]=$button;
}报错提示:Fatal error: Using $this when not in object context in D:\Wamp\Apache\htdocs\1.01\this.php on line 9
解决方案 »
- PHP从字符串中截取数字
- [求助]添加数据后出现表崩溃需要修复
- php 循环给函数赋值
- mysql数据库,一张表里有一行的一个字段是乱码
- 各位高手,帮忙想一下,我要用nginx伪静态,http://127.0.0.1/phurl/vP3g8 http://127.0.0.1/phurl?aid=
- PHP命令行中运行 pear help 出现错误
- 如何在PHP中获得JS中的变量
- 关于从URL中获得参数 和GET post 的提交的问题 我如何保持URL中的参数
- 写函数高手请帮忙。。。。
- php服务器与ios客户端的http通信问题
- 如何自动循环叠加打开ID=1这种形式的网站
- php提示错误 mysql_fetch_array() expects parameter 1 to be resource, boolean given
不久可以单独输出view和update了么?
$template='{view} {update} {delete}';
echo $template;
?>
output:
{view} {update} {delete}
view ,update,delete 分别对应yii grid中的查看按钮,更新按钮和删除按钮组件,需要哪个就加哪个。
比如,只需要view按钮:
$template='{view}';