我有一堂课
<?php
class cms{
private $dataset;
private $columns;
private $configs;
public function __construct(){
global $frw, $dbg;
$this->configs =array();
}
public function __get($key){
if(array_key_exists($key, $this->configs)==true){
return $this->configs[$key];
}else{
throw new Exception('Unable to get value from configuration. '.$key);
}
}
public function __set($key, $value){
if(array_key_exists($key,$this->configs)){
throw new Exception('Unable to set configuration. '.$key);
}else{
$this->configs[$key] = $value;
}
}
public function exists($key){
if(isset($this->configs[$key])){
return true;
}else{
return false;
}
}
public function load(){
}
}
?>
$cms = 新 $cms;
我需要在页面上设置一个变量来实例化对象并且在每个页面中全局可用(在会话期间)。我不想要会话变量,也不想使用全局变量。有没有办法在页面之间传递 $dataset 并在 xajax 加载中调用 $cms->dataset。我一直在想我应该能够设置一个变量$dataset = $cms->__get('dataset');