声明新类时方法的致命错误

时间:2015-06-21 07:34:32

标签: php

我有这个奇怪的错误。 我有DB课和Live课。 Live类不是扩展DB类。 我无法理解为什么当我宣布New Live这件事发生时。 错误是:

Notice: Undefined property: Live::$isOff in /home/main/Database/DB.class.php on line 570

Fatal error: Call to undefined method Live::Query() in /home/main/Database/DB.class.php on line 574

这就是我在这一行:

ON DB.Class.php

public function setCharset($charset) {
    if (self::$isOff){
        return false;
    }
    self::$charset = $charset;
    self::Query("SET NAMES '".$charset."'");
    return self;
}

ON Live.Class.php

class Live
{

   protected $PaypalLogo = '';

   protected $isQA = null;
   protected $siteURL = null;

   public function __construct() {

    DB::setCharset("utf8");//Setting charset here and that is gives Fatal Error.

    if (strstr($_SERVER['SERVER_NAME'], "ba.")) {
        $this->isQA = true;
        $this->siteURL = "http://ba.live.com";

    }
    else {

        $this->isQA = false;
        $this->siteURL = "http://www.live.com/";
    }
  }

感谢您的任何建议。

1 个答案:

答案 0 :(得分:0)

我发现了问题。这是因为没有DB的实例,因此,它采用了Live的实例。