What does $this actually mean> Codeigniter

后端 未结 6 860
攒了一身酷
攒了一身酷 2020-12-09 11:25

Silly question I know,

From all the tutorials they do not explain why they use $this.

Is $this like an object from a base class in Codeigniter?

Any e

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 12:02

    To actually answer your question, $this actually represents the singleton Codeigniter instance (which is actually the controller object).

    For example when you load libraries/models, you're attaching them to this instance so you can reference them as a property of this instance.

    Another way to get this instance in codeigniter is the get_instance() function that you use when building portable libraries.

提交回复
热议问题