get_instance() in Codeigniter: Why assign it to a variable?

后端 未结 7 1699
清酒与你
清酒与你 2020-12-04 08:42

In Codeigniter, get_instance() is a globally available function that returns the Controller super-object which contains all the currently loaded classes (it ret

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 09:16

    Why is it recommended to assign get_instance() to a variable rather than calling it directly?

    Most probably, it is recommended to maintain backward compatibility with php4, where objects were not passed by reference by default, but were cloned.

    Is there any reason not to take this approach?

    Only if you want your application to run on outdated php installations

提交回复
热议问题