des*_*ing 7 php oop fatal-error
如果有错误,这是部分.
致命错误:在第6行的/pb_events.php中不在对象上下文中时使用$ this
第6行是: $jpp = $this->vars->data["jpp"];
function DoEvents($this) {
global $_CONF, $_PAGE, $_TSM , $base;
$jpp = $this->vars->data["jpp"];
$cache["departments"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_departments]}");
$cache["locations"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_location]}");
$cache["names"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_names]}");
$cache["categories"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_categories]}");
Run Code Online (Sandbox Code Playgroud)
非常感谢!欣赏!
use*_*291 14
$这只在方法中有意义,而不是在函数中
还行吧
class Foo {
function bar() {
$this->...
Run Code Online (Sandbox Code Playgroud)
这不是
function some() {
$this->
Run Code Online (Sandbox Code Playgroud)
//编辑:没有注意到他将"$ this"作为参数传递
建议:简单地用"$ somethingElse"替换"$ this"
根据我的评论.你想使用$this
传递变量而php不允许它在类方法体外.
function DoEvents($obj) {
global $_CONF, $_PAGE, $_TSM , $base;
$jpp = $obj->vars->data["jpp"];
$cache["departments"] = $obj->db->QFetchRowArray("SELECT * FROM {$obj->tables[job_departments]}");
$cache["locations"] = $obj->db->QFetchRowArray("SELECT * FROM {$obj->tables[job_location]}");
$cache["names"] = $obj->db->QFetchRowArray("SELECT * FROM {$obj->tables[job_names]}");
$cache["categories"] = $obj->db->QFetchRowArray("SELECT * FROM {$obj->tables[job_categories]}");
Run Code Online (Sandbox Code Playgroud)