dongmou9260 2011-09-02 02:04
浏览 57
已采纳

静态呼叫与动态呼叫:哪一个具有更好的性能?

For example this is my class:

<?php 
 Class Example
 {
  public function example_function()
  {
   echo "example code";
  }
 }
?>

Which one of the following will be best, performance-wise?

1)

Example::example_function();

2)

$example = new Example();
$example->example_function();

What is the difference between them?

  • 写回答

4条回答 默认 最新

  • dongpi2503 2011-09-02 02:14
    关注

    It not a matter of performance. It really isn't. The difference, if there is one, is so minuscule as to be hardly measurable.

    If you need to design your class with static methods, use static methods.
    If you need to instantiate your class, you have no choice but to use object methods.

    It's a class design decision that has nothing to do with performance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器