You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

33 lines
730 B

<?php
include_once SERVER_ROOT . '/library/viewtpl/iDisplay.php';
class DisplayJson implements iDisplay {
private $varname;
private $view;
public function __construct($varname = ""){
if($varname !=""){
$this->varname = strip_tags($varname);
}
}
public function setView($view){
$this->view = $view;
}
public function execute() {
// 如果是接口,屏蔽json数据中的公用数据
if($this->view['_is_api']) {
foreach ($this->view as $k =>$v) {
if(substr($k, 0, 1)=='_') unset($this->view[$k]);
}
}
$jsonStr = json_encode($this->view);
if(isset($this->varname) && $this->varname!=""){
$jsonStr = $this->varname."=".$jsonStr;
}
echo $jsonStr;
}
}