Why does an error appear when accessing fetch?
RiVol
RiVol 2018-03-05 19:47:14
0
4
1654

// Get a single query result

public static function fetch($sql){

return $this->conn->query($sql)->fetch( PDO::FETCH_ASSOC);

}

Error:

Fatal error: Using $this when not in object context in D:\Web\api\Db.php on line 79

RiVol
RiVol

老铁们,稳!

reply all(4)
寻觅 beyond

Check it, it should be that there are a few more curly braces in front of this method, causing your fetch to be defined outside the class, so this situation occurs

phpcn_u58808

111111111111

炎

Can I take a screenshot of the entire page of code?

辉

Fatal error, there is no such object in the $this context, view the content of the variable

  • reply According to the writing method in the video, why is an error reported?
    RiVol author 2018-03-05 21:28:31
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template