Php 构造中未定义的变量

Php 构造中未定义的变量,php,variables,undefined,construct,Php,Variables,Undefined,Construct,当我试图在_构造中定义变量时,它仍然会给我一个未定义变量的错误。你能帮忙吗 <?php class view { public $model; function __construct($url,$root,$model,$common_model,$common_view,$alt_root,$it_selected,$hr_selected,$finance_selected) { $this->it_selected = $it_se

当我试图在_构造中定义变量时,它仍然会给我一个未定义变量的错误。你能帮忙吗

    <?php



    class view {

public $model;


function    __construct($url,$root,$model,$common_model,$common_view,$alt_root,$it_selected,$hr_selected,$finance_selected) {

    $this->it_selected = $it_selected;
    $this->hr_selected = $hr_selected;
    $this->finance_selected = $finance_selected;
    $this->url = $url;
    $this->model = $model;
    $this->common_model = $common_model;
    $this->common_view = $common_view;
    $this->root = $root;
    $this->alt_root = $alt_root;


    $this->loader();


}

我仍然收到it_selected,hr_selected和finance_selected未定义。

您必须在PHP类中定义它们,就像您定义的$model一样。换句话说,在public$model下,添加private$it_selected;或者public,对构造函数中使用的所有var u执行此操作。请完整地向我们显示所有错误消息。另外,在实例化类时,您确定它与传递到构造函数中的变量无关吗?例如,新视图$a、$b、$c、…,都是$a、$b、$c、。。。定义的变量?是否使用所有9个参数调用_构造?最接近您的错误是仅使用6个参数调用_构造,这导致3个警告和3个通知。