Im receiving an error as stated above. Its referring to my return statement. Any one got any clues on this?! Thankful for all help! Regards!
public function getPosts() {
$result = $this->db->query("SELECT * FROM posts");
$posts = array();
while($posts = $result->fetch_assoc()) {
array_push($posts, new Post($post['id'], $post['created'], $post['author'], $post['title'], $post['body']));
}
}
return $posts;
Your return statement should come before the last closing brace.
while($posts = $result->fetch_assoc()) {
array_push($posts, new Post($post['id'], $post['created'], $post['author'], $post['title'], $post['body']));
}
return $posts;
}
Your return
statement needs to be inside the function getPosts()
. Currently it is outside or you have one }
on the wrong line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With