Home>Article>Backend Development> Usage example of PHP7 anonymous class (code)

Usage example of PHP7 anonymous class (code)

不言
不言 forward
2019-02-12 14:07:28 1696browse

The content of this article is about the usage examples (code) of PHP7 anonymous classes. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

num = 1; } protected function bar(): int { return 10; } public function drive() { return new class($this->num) extends An{ protected $id; public function __construct($num) { $this->id = $num; } public function ea() { return $this->id + $this->age + $this->bar(); } }; } } echo (new An())->drive()->ea();
rrree

The above is the detailed content of Usage example of PHP7 anonymous class (code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete