$这是什么意思在类定义? [英] what does $this mean within a class definition?

查看:102
本文介绍了$这是什么意思在类定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我继续尝试改善自己作为一个初级PHP开发人员,我已经开始尝试打破其他人的工作。

As I continue to try and improve myself as a junior PHP developer, I have started to try break down other peoples work. I find it helps me understand, as well as giving me ideas.

我在PHP类中没有得到两个东西,这意味着什么,这意味着什么,什么数组

Two things I do not get, in a PHP class, what $this means, and what array($this,'some_function') means when I would expect a function name in it's place.

非常感谢

推荐答案

请参阅 PHP课程手册和对象 $ this 是指对象实例。另请参阅以下问题:

Please see the PHP Manual on Classes and Objects. $this refers to the object instance. Also see these questions:

  • What does the variable $this mean in PHP?
  • What is the meaning of $this

array($ this,'some_function')请参阅 PHP手册回调。在接受回调的方法和函数中,例如 call_user_func ,意味着调用 some_function > $ this 。请参阅

For array($this,'some_function') see the PHP manual on callbacks. In methods and functions that do accept callbacks, like call_user_func, it means call the method some_function on $this. See

将此标记为CW,因为它不是作为答案,而是作为重复的closevoting的原因

Marking this as CW because it's not meant as an answer but the reason for closevoting as duplicate

这篇关于$这是什么意思在类定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆