Home  >  Article  >  Backend Development  >  php5.3中新增多的_invoke方法

php5.3中新增多的_invoke方法

WBOY
WBOYOriginal
2016-06-13 11:01:141036browse

php5.3中新增加的_invoke方法
在php 5.3中,发现了新增加的invoke方法,例子如下:
class Demo{
        public function __invoke(){
                echo "测试";
        }
}
$demo = new Demo;
$demo();
?>
这样的话,直接用对象名就当函数使用了,调用的是_invoke的方法;
输出
测试

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn