我正在尝试显示放入表格中的信息。这是我的代码让我感到困惑:
<?php
//include the person class
require ('objects/classes/person.class.php');
$person = new Person();
//set person attributes
$person->first_name = $_POST["first_name"];
$person->last_name = $_POST["last_name"];
$full_name = $person->retrieve_full_name();
//display the name
echo "Your full name is " . $full_name . ". <br />";
echo "Your first name is " . $person . ". <br />";
echo "Your last name is " . $person . ".";
?>
这是我的课程代码:
class Person {
//private attributes
private $first_name;
private $last_name;
//get function
public function __get($name){
return $this->$name;
}
//set function
public function __set($name, $value){
$this->$name=$value;
}
public function retrieve_full_name(){
return $full_name = $this->first_name . ' ' . $this->last_name;
}
}
?>
提交时我也收到此错误:您的全名是 www dddd。可捕获的致命错误:第 13 行 /home/gaddough/cit21500/exercises/objects/login.php 中的 Person 类对象无法转换为字符串
我知道它在某个地方很容易解决,但我无法弄清楚任何帮助都会很棒!