- var_dump: documentation ( source)
<?php
class Author
{
private $name;
private $id;
public function __construct($id)
{
$this->id = $id;
unset($this->name);
}
public function name()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function id()
{
return $this->id;
}
public function __get($name)
{
echo 'we dont have all the pieces, look em up'; die;
}
}
class Post
{
private $id;
private $title;
private $body;
private $author;
public function __construct($id, $title, $body, $author)
{
$this->id = $id;
$this->title = $title;
$this->body = $body;
$this->author = $author;
}
public function id()
{
return $this->id;
}
public function title()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
}
public function author()
{
return $this->author;
}
public function setAuthor(Author $author)
{
$this->author = $author;
}
}
$post = new Post(111, 'A Song of Ice and Fire', 'My book is the shiz', new Author(222));
//var_dump($post->author()->name());
var_dump($post->author()->name);