I asked for help. I just got in touch with PHP and wrote the following section, $ x-& gt; name (); why is it empty? PHPcodeinterfaceman {functiontalk ();} abstractclassperson {I have a question for help
I just got started with PHP and wrote the following section, $ x-> name (). why is it empty?
PHP code
Interface man {function talk ();} abstract class person {abstract function name (); abstract function age (); var $ c = "this is an abstract class
";} Class xiaoming extends person implements man {function name () {echo (" xiaoming
");} Function age () {echo (" 12 "."
");} Function talk () {echo (" love
") ;}} Class xiaoli extends person implements man {var $ mingzi; function _ construct ($ mingzi) {$ this-> mingzi = $ mingzi;} function name () {echo ($ this-> mingzi."
");} Function age () {echo (" 13
");} Function talk () {echo (" you ") ;}$ p = new xiaoming (); $ p-> name (); $ p-> age (); $ p-> talk (); $ x = new xiaoli ("xiaoli"); $ x-> age (); $ x-> name (); $ x-> talk ();
------ Solution --------------------
_ Construct
------ Solution --------------------
_ Construct double underline
Since you have used the interface, name and age should not be exposed to the outside world.