【发布时间】:2016-12-24 12:42:53
【问题描述】:
我没有看到任何类似的主题,所以我发布了一个新主题。
首先,我很抱歉我的英语不好。
我想要一个公共函数,它可以将数据库中的值存储在全局变量中,并使用该值让 php 脚本选择网站模板。你能帮帮我吗?
private $page_title = null;
private $body_title = null;
private $body_content = null;
private $template = null;
private $settings = array();
private $file_template = 'content';
private $path = 'templates/';
private $parse_page = false;
global $template2;
public function GetHASH()
{
return $this->hash;
}
function Tema()
{
global $db,$user_class;
if($user_class->authorized)
{
$row = $db->sql("SELECT * FROM `ucp_users` WHERE `user_hash` = '".$this->GetHASH()."'");
$array = $db->get_array($row);
$template2 = $array['template'];
}
else
{
$template2 = '1';
}
return $template2;
}
function __construct() {
switch($template2) {
default:
{
$template_name = 'dsa/';
$template2 = 1;
}
break;
case 0: $template_name = 'lsrp/';
break;
case 1: $template_name = 'dsa/';
break;
}
$this->path = $this->path.''.$template_name;
}
谢谢。
【问题讨论】:
-
那么你已经拥有的究竟出了什么问题?
-
这是在课堂上吗?
-
是在一个类中,并且函数“Tema”不从数据库加载变量。 $template2 对于我能做的所有事情都是 0
标签: php