Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Jose da Silva’s Blog: Revisiting PHP 5.3 __invoke magic method

Jose da Silva’s Blog: Revisiting PHP 5.3 __invoke magic method

In a new post to his blog Jose da Silva briefly looks at a feature that was introduced in the PHP 5.3.x series of the language – the __invoke magic method.

PHP version 5.3 introduced a new magic method designed __invoke, this method is called when a script tries to call an object as a function. [...] As php cannot accommodate pseudo-first-class functions, the __invoke method can be used to suppress this language limitation. On other hand you can use this for simpler things as pass a function around.

He includes a simple code example that shows a basic class being called via a variable name – $c(‘ford’) – and the result of its __invoke method being called. He notes that the method, in his opinion, could make for less clean code.

Source: http://www.phpdeveloper.org/news/15392

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Listopad 8th, 2010 in WEB and PHP Development.

Leave a response: