我的一些問題與我的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/>';
?>
歡迎堆棧溢出! –