Database.php
// selecting query
public function select($query){
And here-> $result = $mysqli->query($query);
if($result->num_rows > 0){
return $result;
}
else{
return false;
}
Header.php
<?php
include 'libraries/config.php';
include 'libraries/database.php';
//creating new object of database
$db = new database();
$query = "select * from posts order by id desc";
giving error here -> $posts = $db->select($query);
?>
致命错误:未捕获错误:在C:\ xampp \ htdocs \ OOP \ libraries \ database.php:40中对成员函数query()的调用为null:堆栈跟踪:#0 C:\ xampp \ htdocs \ OOP \ include \ header.php(11):database-> select('select * from p ...')#1 C:\ xampp \ htdocs \ OOP \ index.php(3):include('C:\ xampp \ htdocs ...')#2 {main}在第40行的C:\ xampp \ htdocs \ OOP \ libraries \ database.php中抛出