When do I use static variables/functions in php?

前端 未结 8 1022
天涯浪人
天涯浪人 2020-11-30 20:32

I am refreshing myself on OOP with PHP and I saw an example of setting functions and/or variables as static. When and why would I set a variable/function to static? I\'ve

8条回答
  •  Happy的楠姐
    2020-11-30 21:14

    Generally using static function you can optimize the speed as well as memory and the scope of method should not be changed its should be static in nature and you can access the objects static properties ,methods without initiating them so saves the memory in mean time.

提交回复
热议问题