php 闭包的作用
高洛峰
高洛峰 2016-11-07 09:58:28
0
1
991
  public function __construct($config)
    {    parent::__construct();    $this['config'] = function () use ($config) {        return new Config($config);
    };
    ...
    其中    $this['config'] = function () use ($config) {        return new Config($config);
    能不能直接写成这样:    $this['config'] = new Config($config);
    有什么优势?


高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
三叔

closure会在真正调用的时候才new一个Config, 这样就可以实现了lazy load.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!