__invoke()を使う

__invoke() – 親方、空から覚え書きが!

クラスで

[php]
public function __invoke()
{
echo ‘hoge’;
}
[/php]

というメソッドを宣言しておくと、

[php]
$a = new A();
$a();
[/php]

なんて感じで使えるみたいです。面白い!

関連する記事:

Powered by

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">