PHP补基础

WBOY
Release: 2016-06-23 14:16:26
Original
1044 people have browsed it

近期在看YII

public $template='{view} {update} {delete}';
Copy after login

以上这种写法,如何单独输出{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;		}
Copy after login

报错提示:Fatal error: Using $this when not in object context in D:\Wamp\Apache\htdocs\1.01\this.php on line 9


回复讨论(解决方案)

public $template='{view} {update} ';
不久可以单独输出view和update了么?

<?php    $template='{view} {update} {delete}';    echo $template;  ?>
Copy after login
Copy after login

output:
{view} {update} {delete}

<?php    $template='{view} {update} {delete}';    echo $template;  ?>
Copy after login
Copy after login

output:
{view} {update} {delete}

view ,update,delete 分别对应yii grid中的查看按钮,更新按钮和删除按钮组件,需要哪个就加哪个。
比如,只需要view按钮:
$template='{view}';

这个我也知道的,我想知道如何单独输出view,update啊

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template