Define a parent class Person (person), including two attribute members xm (name), xb (gender) and a constructor. xm and xb cannot be read and written directly in the main program. Name, xb are completed in the constructor. Initialization of gender.
Define a subclass teacher (teacher) inherited from Person, including the attribute gh (employee number) and a constructor. You cannot directly read and write gh in the main program. The constructor can be used to initialize all data members. And define a method in the subclass to output all teacher information, and define a destructor to display "Goodbye".
There is currently a teacher "李思", gender "male", and job number 123. Please initialize it with this data and output
<?php
class Person
{
protected $xm;
protected $xb ;
function __construct()
{
$this->xm = '李思';
$this->xb = 'Male';
}
##}## class Teacher extends Person
{
protected $gh;
## function __construct()
{public function message()
{ return "The name is: {$this->xm} Gender is: {$this->xb} Job number is: {$this->gh}"; }function __destruct( )
{ // return 'Goodbye!'; echo 'Goodbye! '; }}
##$teacher = new Teacher();echo $teacher->message();
You posted it, I was stunned by what you said