为什么我收到此错误:对象无法转换为字符串?
Catchable fatal error: Object of class Card could not be converted to string in /f5/debate/public/Card.php on line 79
这里是代码:
public function insert()
{
$mysql = new DB(debate);
$this->initializeInsert();
$query = "INSERT INTO cards
VALUES('$this->$type','$this->$tag','$this->$author->$last','$this->$author->$first',
'$this->$author->$qualifications','$this->$date->$year','$this->$date->$month',
'$this->$date->$day','$this->$title', '$this->$source', '$this->$text')";
$mysql->execute($query);
}
(79号线是$query
且功能Card
类的一部分)
所有的声明Card
:
public $type;
public $tag;
public $title;
public $source;
public $text;
public function __construct() {
$this->date = new Date;
$this->author = new Author;
}
改变线79这话:
$query = "INSERT INTO cards
VALUES('$this->type','$this->tag','$this->author->last','$this->author->first',
'$this-$author->qualifications','$this->date->year','$this->date->month','$this->date->day',
'$this->title', '$this->source', '$this->text')";
现在我得到这个错误:
Catchable fatal error: Object of class Author could not be converted to string in /f5/debate/public/Card.php on line 79
这是因为'$ this- $ author-> qualifications' – quantumSoup 2010-07-08 05:51:35