This one is tricky because of the new syntax. Also echo-ing $teacher->$isAlive;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <!DOCTYPE html> <html> <head> <title>Reconstructing the Person Class</title> <link type='text/css' rel='stylesheet' href='style.css'/> </head> <body> <p> <?php class Person { public $isAlive = true; public $firstname; public $lastname; public $age; } $teacher = new Person(); $student = new Person(); echo $teacher->$isAlive; ?> </p> </body> </html> |