我有一个名为Job_search
的控制器
在我的Job_search.php中,我声明了一些变量:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Job_search extends CI_Controller {
public $keyword='Driver';
public $location='KL__ Kerala KT__ Kottayam Vaikom';
public $district='78';
public $listing_type = 'Job';
public $listings_per_page = '10';
public $page='1';
public function __construct() {
parent::__construct();
$this->load->model('Job_search_model');
}
public function index() {
$result=$this->Job_search_model->get_job_search_result($keyword,$location,$district,$listing_type,$listings_per_page,$page);
}
}
我收到了这些错误:
Undefined variable: keyword
Undefined variable: location
Undefined variable: district
Undefined variable: listing_type
Undefined variable: listings_per_page
Undefined variable: page
答案 0 :(得分:2)
public function index()
{
$result=
$this->Job_search_model->get_job_search_result(
$this->keyword,
$this->location,
$this->district,
$this->listing_type,
$this->listings_per_page,
$this->page);
}
试试这个,你需要$this->
infront,你在课堂上调用一个变量,所以$this->test
就是如何调用它。
答案 1 :(得分:0)
您可以使用班级中的this
关键字来访问它:
$this->varibale_name;