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";}
the return of the vardump : (0) "" string(3) "hoi" and it echo's false
index.php
$boek3 = new Book();
$boek3->id = "";
$boek3->title = "hoi";
$boek3->author = "bla";
$boek3->isbn = "bla";
$boek3->save();
I had to use this code because my teacher and reader said so. Normally i can understand what's going wrong in the reader even when my teacher has high hopes that it's correct. but this one i don't know why later on he make's my $this->title an empty string.