我非常小心地创建了这个类,但我不确定它有什么问题。如果我没有任何内容,代码运行完美,
class TemplateOne{
}
但是一旦我运行这段代码,它就会中断,
<?php
class TemplateOne {
//Properties
protected $_bgColor;
protected $_logoImagePath;
protected $_headerText;
protected $_leftContentHeader;
protected $_rightContentHeader;
protected $_leftContentBody;
protected $_rightContentBody;
protected $_footer;
protected $_mediaIframe;
protected $_mediaHeight = '';
protected $_mediaWidth = '';
//DB communication
public $DB;
//Constructor
public function __construct(){
//Connect database in construct and close connection in destruct
$config = array();
$config['host'] = 'localhost';
$config['user'] = 'root';
$config['pass'] = 'root';
$config['database'] = 'fanpage_application';
$this->DB = new DB($config);
//init variables
populateDataFromDataBase();
}
//Functions
public function populateDataFromDataBase() {
//Get bgcolor
$this->DB->("SELECT backgroundimage FROM template_style_data WHERE styleid='#list_level'");
$data = $this->DB->Get();
foreach($data as $key => $value)
{
echo $value['backgroundimage'];
}
}
//Getters
public function getBgColor()
{
return $this->_bgColor;
}
public function getLogoImagePath()
{
return $this->_logoImagePath;
}
public function getHeaderText()
{
return $this->_headerText;
}
public function getLeftContentHeader()
{
return $this->_leftContentHeader;
}
public function getRightContentHeader()
{
return $this->_rightContentHeader;
}
public function getLeftContentBody()
{
return $this->_leftContentBody;
}
public function getRightContentBody()
{
return $this->_rightContentBody;
}
public function getFooter()
{
return $this->_footer;
}
public function getMediaIframe()
{
return $this->_mediaIframe;
}
//Setters
public function setBgColor($bgColor)
{
$this->_bgColor = $bgColor;
}
public function setLogoImagePath($logoImagePath)
{
$this->_logoImagePath = $logoImagePath;
}
public function setHeaderText($headerText)
{
$this->_headerText = $headerText;
}
public function setLeftContentHeader($leftContentHeader)
{
$this->_leftContentHeader = $leftContentHeader;
}
public function setRightContentHeader($rightContentHeader)
{
$this->_rightContentHeader = $rightContentHeader;
}
public function setLeftContentBody($leftContentHeader)
{
$this->_leftContentBody = $leftContentHeader;
}
public function setRightContentBody($rightContentBody)
{
$this->_rightContentBody = $rightContentBody;
}
public function setFooter($footer)
{
$this->_footer = $footer;
}
public function setMediaIframe($mediaIframe)
{
$this->_mediaIframe = $mediaIframe;
}
}
?>