I’m newbie in PHP OOP. I need to create a class Place that may have objects of the class Token. How to do this correctly?
class Token {
var $value;
function setValue($value) {
$this->value = $value;
}
function getValue() {
return $this->value;
}
}
class Place {
var $token;
function addToken($token) {
$this->token = $token;
}
function getToken() {
return $this->token;
}
}
//...
Then I need to create objects of above-defined classes and access Token objects from Place objects:
$t = new Token();
$t->setValue(5);
$p = new Place();
$p->addToken($t);
echo $p->getToken()->getValue;
change
to
and that’s all.