$this->config->get()
我正在阅读别人的代码(需要对其进行一些更改),并且我陷入了这个功能。它可能与 MVC 方法有关,并且在网络上很常见(我发现了很多谷歌结果),但我找不到它实际的作用。
我猜这是主要基于 MVC 的 CMS/PHP 平台通用的标准方法,但我找不到它的编码位置或用途?
这是供参考的代码片段
foreach ($results as $result) {
if ($this->config->get($result['key'] . '_status') && ($this->config->get($result['key'] . '_position') == 'left')) {
$module_data[] = array(
'code' => $result['key'],
'sort_order' => $this->config->get($result['key'] . '_sort_order')
);
$this->children[] = 'module/' . $result['key'];
}
}
我知道必须有一个带有方法 get() 的对象配置
但是包含此代码的类(类 ControllerCommonColumnLeft)和它扩展自的类(扩展控制器)都没有这些,这就是为什么我问...
I'm reading someone else's code (need to make some changes in it) and I'm stuck at this function. Its probably related to MVC approach and is common on the web (i found a lot of google results) but i couldn't find what it actually does.
I'm guessing it's a standard method common to major MVC-based CMSes/PHP platforms, but I can't find where it's coded or what it does?
here's the code snippet for reference
foreach ($results as $result) {
if ($this->config->get($result['key'] . '_status') && ($this->config->get($result['key'] . '_position') == 'left')) {
$module_data[] = array(
'code' => $result['key'],
'sort_order' => $this->config->get($result['key'] . '_sort_order')
);
$this->children[] = 'module/' . $result['key'];
}
}
I understand that there must be an object config with a method get()
But neither the class that contains this code (class ControllerCommonColumnLeft), nor the class that it extends from (extends Controller) has any of these, that is why I ask...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于它在哪里使用。在 PHP 中,
$this
指的是“当前类”,因此,例如,在下面的代码中,$this
就像是在说“在类中查找”Person
for ...”一旦您开始使用
static
类,情况可能会有点复杂,但您现在不必担心这些。It depends where it's used. In PHP,
$this
refers to "the current class", so if you have, for example, in the following code,$this
is like saying "Look in the classPerson
for ..."It can be a little more complicated once you start using
static
classes, but you shouldn't worry about those for now.