Php 控制器中未定义的变量

Php 控制器中未定义的变量,php,codeigniter-3,Php,Codeigniter 3,我有一个名为Job\u 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'; pu

我有一个名为
Job\u 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);
  }
}

尝试此操作,您需要
$this->
在前面,您正在从类中调用变量,因此
$this->test
是如何调用它的。

您可以使用
this
关键字在类中的任意位置访问它:

$this->varibale_name;

使用
$this->关键字
$this->位置
。。。等等,检查一下
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->varibale_name;