DEV Community

Discussion on: PHP - Elegant method call

Collapse
 
suddenlyrust profile image
Ruslan

Thank you for your comment. I tried your example. But somehow the invoke method is never called 🤔. Could you help me with that?

Here is a link to a "Online PHP Compiler": repl.it/repls/DisastrousViciousFeed

class Something
{
    public function __invoke($params)
    {
          var_dump('Hi there 👋. I invoked myself 😁');
    }
}

$something = new Something(['dev.to', 'is', 'really', 'cool']);

var_dump('Did the invoke work? 😕');