New users learn PHP problems and find that the code in the book does not inherit the PHP Basics.
I found a piece of code in the book. I found it wrong after I typed it ..
Name = $ name; $ this-> sex = $ sex; $ this-> age = $ age;} function say () {echo "My name ". $ this-> name. ", Gender ". $ this-> sex. ", age ". $ this-> age."
";} Function run () {echo $ this-> name." walking
";}} Class Student extends Person {var $ school; function study () {echo $ this-> name." learning ". $ this-> school ."
";}} Class Teacher extends Student {var $ wage; function teaching () {echo $ this-> sex. "In Progress ". $ this-> school. "Teaching, the monthly salary is ". $ this-> wage."
";}}$ Teacher1 = new Teacher (" Michael Zhang "," male ", 40); $ teacher1-> school =" Shenyang Institute of Technology "; $ teacher1-> wage = 3000; $ teacher1-> say (); $ teacher1-> run (); $ teacher1-> teaching ();?>
Here, the teaching method in the Teacher class may not reach $ this-> name .. What I can get from the book is what I wrote wrong?
Reply to discussion (solution)
Yes $ this-> sex cannot get data.
Amount .... I am so careless. the above variable defines the private attribute, and of course it cannot be obtained...
Birds of the same dish fly over .........
You are not wrong. you are not wrong in the book!
It's just that the error check levels are different.
Error_reporting = E_ALL ^ E_NOTICE
It is consistent.
You are not wrong. you are not wrong in the book!
It's just that the error check levels are different.
Error_reporting = E_ALL ^ E_NOTICE
It means that the moderator is strong, refreshing, and hard-working!
Private $ name;
Private $ sex;
Private $ age;
Private to public