class MyClass { public function __call($name, $arguments) { echo "Method '$name' does not exist in this object"; } } $obj = new MyClass; $obj->myUndefinedMethod(); // Output: Method 'myUndefinedMethod' does not exist in this object
class MyClass { public function __call($name, $arguments) { if ($name == "sayHello") { echo "Hello, " . $arguments[0]; } } } $obj = new MyClass; $obj->sayHello("John"); // Output: Hello, JohnThis method is used in various PHP libraries, including Laravel, Symfony, and Zend Framework.