Beispiel #1
0
    {
        if (isset($this->{$property})) {
            return $this->{$property};
        } else {
            return $property . ' unknown' . "\n";
        }
    }
    public function __set($property, $value)
    {
        $this->{$property} = $value;
    }
    public function __toString()
    {
        return 'Hotel to string';
    }
    public function __sleep()
    {
        return ["country", "location"];
    }
    public function __invoke()
    {
        echo 'Calling object as function' . "\n";
    }
}
$hotel = new Hotel();
echo $hotel->size;
$hotel();
$hotel->location = 'Berlin';
echo $hotel->name() . '/' . $hotel->location . ' has ' . Hotel::getHotelSettings()['rooms'] . ' rooms' . "\n";
echo $hotel;
echo serialize($hotel);