<?php
class Work{
var $name = 'name';
function getName(){
return $this->name;
}
}
class Worker{
var $name = 'Ivan';
var $work = null;
function __construct($work){
$this->work = $work;
}
function getWork(){
return $this->work;
}
}
$microsoft = new Work();
$ivan = new Worker($microsoft);
echo $ivan->getWork()->getName();
?>
PD9waHAKY2xhc3MgV29ya3sKCXZhciAkbmFtZSA9ICduYW1lJzsKCWZ1bmN0aW9uIGdldE5hbWUoKXsKCQlyZXR1cm4gJHRoaXMtPm5hbWU7Cgl9Cn0KY2xhc3MgV29ya2VyewoJdmFyICRuYW1lID0gJ0l2YW4nOwoJdmFyICR3b3JrID0gbnVsbDsKCWZ1bmN0aW9uIF9fY29uc3RydWN0KCR3b3JrKXsKCQkkdGhpcy0+d29yayA9ICR3b3JrOwoJfQoJZnVuY3Rpb24gZ2V0V29yaygpewoJCXJldHVybiAkdGhpcy0+d29yazsKCX0KfQokbWljcm9zb2Z0ID0gbmV3IFdvcmsoKTsKJGl2YW4gPSBuZXcgV29ya2VyKCRtaWNyb3NvZnQpOwoKZWNobyAkaXZhbi0+Z2V0V29yaygpLT5nZXROYW1lKCk7Cj8+