代码之家  ›  专栏  ›  技术社区  ›  bcmcfc

尝试获取非对象的属性,以及类似的错误-性能命中?

  •  4
  • bcmcfc  · 技术社区  · 14 年前

    如果我有代码生成上面的注意事项,类似的,比如数组的未定义偏移量,会添加 isset() empty() 除了重新发送错误通知之外,检查还能提高脚本的性能吗?

    编辑:为了澄清,我想要错误报告,我知道ISSET会绕过通知,这个问题更多的是关于性能方面。

    3 回复  |  直到 14 年前
        1
  •  5
  •   lonesomeday    14 年前

    error_reporting

    error_reporting(0);
    

    @

    @$my_array['a'];
    

    isset()

    if (isset($my_array['a'])) {
        $my_array['a'];
    }
    

    a quick benchmarking script

    Turning off error reporting:  6 seconds
    Using error suppression:     18 seconds
    Using isset():                9 seconds
    
        2
  •  1
  •   Surfrdan    14 年前