0

我有一个奇怪的问题,无法进入课堂$_POST,很奇怪,这是问题和错误?类很简单,只是为了演示。

if(isset($_POST['name']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$komentar = new comments($name,$email,$comment);
$komentar->provera();
}

班级:

class comments 
{
public function __construct($name, $email, $comment)
{
$this->name=$name;
$this->email=$email;
$this->comment=$comment;
}
public static function provera()
{
$poruka=$this->comment; 
echo $poruka;
}
}

我收到了这个错误

Fatal error: Using $this when not in object context in 
classes\comments.inc.php on line 12
4

1 回答 1

5

您不能$this在静态方法中使用。除非您需要provera()静态调用,否则请static从其声明中删除关键字。

于 2012-07-29T10:13:51.913 回答