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

php5.3中新增多的_invoke方法

WBOY
Release: 2016-06-13 13:04:16
Original
1077 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template