How to catch the error at the moment when the condition is false and the function does not return the object? I guess that it is necessary to use exceptions, but I never used them, I will be grateful for an example.
class hub{ public function r($condition,$message){ if ($condition){ echo $message; return $this; }else{ return 0; } } } $o=new hub(); $o->r(true,'continue ')->r(true,'continue')->r(true,'continue')->r(false,'stop')->r(true,'continue');