首頁 > 後端開發 > php教程 > Using this when not in object context in_PHP教程

Using this when not in object context in_PHP教程

WBOY
發布: 2016-07-13 10:51:00
原創
1081 人瀏覽過



问题
Using $this when not in object context in
解决方法
private $link_id;

private $sql;

private $getAll = array();

private $getOne = array();

private $qRes;

public static function _init(&$dsn, $pconnect = FALSE, $halt = TRUE) {

if(!is_array($dsn)) exit('Error, Dsn not is array');

$dsn['host'] = (isset($dsn['host']))?$dsn['host']:'localhost';

$dsn['login'] = (isset($dsn['login']))?$dsn['login']:'root';

$dsn['dbpwd'] = (isset($dsn['dbpwd']))?$dsn['dbpwd']:NULL;

$dsn['db'] = (isset($dsn['db']))?$dsn['db']:'test';

$dsn['char'] = (isset($dsn['char']))?str_replace('-', NULL, $dsn['char']):'utf8';

if($pconnect) {

if(!$this->link_id = @mysql_pconnect($dsn['host'], $dsn['login'], $dsn['dbpwd'])) {

$halt && $this->getErrorMsg(__LINE__);

}

} else {

if(!$this->link_id = @mysql_connect($dsn['host'], $dsn['login'], $dsn['dbpwd'])) {# 执行到这里出错。。

$halt && $this->getErrorMsg(__LINE__);

}

}


复制代码


参考答案
static function 中 用 self
参考答案
静态函数里用self!!!!!!!!!!!!!!!
参考答案
....我现在没用static,现在是public function 他还是报错
参考答案
那就是没这方法

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632589.htmlTechArticle问题 Using $this when not in object context in 解决方法 private $link_id; private $sql; private $getAll = array(); private $getOne = array(); private $qRes; public static fun...
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板