PHP: Static and non Static functions and Objects

前端 未结 5 2002
借酒劲吻你
借酒劲吻你 2020-11-27 18:58

What\'s the difference between these object callings?

Non Static:

$var = new Object;
$var->function();

5条回答
  •  眼角桃花
    2020-11-27 19:16

    Static functions, by definition, cannot and do not depend on any instance properties of the class. That is, they do not require an instance of the class to execute (and so can be executed as you've shown without first creating an instance). In some sense, this means that the function doesn't (and will never need to) depend on members or methods (public or private) of the class.

提交回复
热议问题