我的一些问题与我的PHP代码:所有信息返回,但我无法弄清楚为什么我得到的错误。对于我的索引页,我只包含实际使用该类的代码行,除了某些包含的代码外,其他代码实际上没有。我确定这是我建立我的__contstruct,但我不确定这样做的适当方式。我错过了如何从索引页面调用它。警告:缺少参数1
这行代码为我的__construct工程瓦特/ o错误,但我不希望在我的班级分配的变量。
public function __construct(){
$this->user_id = '235454';
$this->user_type = 'Full Time Employee';
}
这是我的课
<?php
class User
{
protected $user_id;
protected $user_type;
protected $name;
public $first_name;
public $last_name;
public $email_address;
public function __construct($user_id){
$this->user_id = $user_id;
$this->user_type = 'Full Time Employee';
}
public function __set($name, $value){
$this->$name = $value;
}
public function __get($name){
return $this->$name;
}
public function __destroy(){
}
}
?>
这是我的索引页我的代码:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$employee_id = new User(2365);
$employee_type = new User();
echo 'Your employee ID is ' . '"' .$employee_id->user_id. '"' . ' your employement status is a n ' . '"' .$employee_type->user_type. '"';
echo '<br/>';
?>
欢迎堆栈溢出! –