$this->admin_model->list_user()
我大部分时间都在用面向对象的 PHP 编写程序。但我是这样写的...
$this->hello_world().
上面的代码是 CodeIgniter,我认为 CakePHP 也遵循相同的编码风格。
请给我一个简单的例子,如何让我的“hello_world”像
$this->something->hello_world().
提前致谢。
苏里亚
最佳答案
没什么特别的; $this->admin_model 是一个包含对象的属性,在所有用途上等同于 $object->method();
一步一步看起来像:
$this->property = new MyObjectWIthADoItMethod();
$this->property->DoIt();
关于php - 如何制作这样的 PHP 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4310856/