这个声明是怎么回事?
$this->load->view("index.php");
我在 CodeIgniter 和其他代码在类中的地方看到了这种语法,因此是“$this”,它引用“load”或其他一些方法,然后指向它看起来像的方法/函数。
有人可以向我解释其中的“负载”是什么吗?不在 CodeIgniter 上下文中,而是在一般 PHP 中。我将如何编写一个允许这样做的类?
我尝试了以下但它不起作用。
<?php
class myObject {
private $x = 0;
function amethod()
{
function embeddedFunc()
{
$this->x += 7;
return $this->x;
}
return embeddedFunc();
}
}
$object = new myObject();
echo $object->amethod->embeddedFunc();
?>
当我看到这个时,我正试图围绕实际发生的事情来思考。