【发布时间】:2018-04-17 07:11:14
【问题描述】:
当我收到此错误时,我正在 PHP 上练习 CI 框架
消息:未定义的属性:Test_controller::$testFunction
我的 Test_controller.php 看起来像这样
class Test_controller extends CI_Controller {
public function test(){
$this->load->model('Test_model');
$test = $this->Test_model->testFunction;
echo "Message : " . $test;
}
而我的 Test_model.php 看起来像这样
class Test_model extends CI_Model{
public function testFunction(){
return "This is a test function on model";
}
我找不到哪里出错了。
感谢您的回答。
【问题讨论】:
-
testFunction是方法,请加括号。
标签: php codeigniter model controller