[英]Fatal error: Using $this when not in object context
I am using smarty templates for pinnaclecart to pull post data from wordpress database so the website can show the blog posts. 我正在使用pinnaclecart的smarty模板从wordpress数据库中提取帖子数据,以便网站可以显示博客帖子。 I fixed IF unexpected error but now it is back to $this.
我修复了IF意外错误,但现在又回到了$ this。 I m stuck :(
我卡住了:(
public_blog.php public_blog.php
EDIT back 编辑回来
function getPosts()
{
$query= $this->db->query("
SELECT * from wp_posts where post_status='publish' AND post_type = 'post'
");
$posts = array();
if ($this->db->moveNext($query, MYSQL_ASSOC))
{
$posts[] = $this->db->col;
}
return $posts;
}
$posts = getPosts();
view()->assign("body", "templates/pages/site/blog.html");
Could not figure IF error part 无法计算IF错误部分
The help will be appreciated. 帮助将不胜感激。
The error in your title leads me to believe that you aren't using a class at all. 标题中的错误让我相信你根本就没有使用过课程。
$this
can only be used in functions that are in a class. $this
只能用于类中的函数。
See related: Fatal error: Using $this when not in object context 请参阅相关: 致命错误:不在对象上下文中时使用$ this
$posts = array();
缺少半冒号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.