illustrate
1. Directly call the object name. When the method is used, the __invoke() method is called.
2. The object itself cannot be used directly as a function. If you remove the __invoke() method and still use the object as a method, an error will be reported.
Example
<?php class autofelix { public function __invoke() { echo 'Do you still want to call me?'; } } $a = new autofelix(); //The object is directly used as a function call $a(); //Result: Do you still want to call me?
The above is an introduction to the PHP magic method __invoke. I hope it will be helpful to everyone.