<?php
class ChainMe {
public function hello() {
echo 'Hello ';
return $this;
}
public function good($is = false) {
if ($is === true) {
echo 'beautiful ';
}
return $this;
}
public function day() {
echo "world!\n\n";
return $this;
}
}
$happy = new ChainMe();
$happy
->hello()
->good(true)
->day();
$meh = new ChainMe();
$meh->hello()->good()->day();
?>