book.php中
public function __construct($id = null)
{
if (!is_null($id)) {
$this->load($id);
}
else
{
$this->save();
}
}
public function save()
{
global $mysqli;
$this->title = htmlentities(html_entity_decode($this->title, ENT_QUOTES),
ENT_QUOTES);
var_dump($this->title);
if(strlen($this->title) > 0)
{
echo $this->title
}
else
{ echo "false";}
vardump的回归:(0)“”string(3)“hoi” 并且它是回声的错误
的index.php
$boek3 = new Book();
$boek3->id = "";
$boek3->title = "hoi";
$boek3->author = "bla";
$boek3->isbn = "bla";
$boek3->save();
我必须使用此代码,因为我的老师和读者都这么说。通常情况下,即使我的老师对这是正确的,我也能理解读者的错误。但是这个我不知道为什么以后他会把我的$ this->标题变为一个空字符串。