Advertisement
ujiajah1

public_contruct

Aug 20th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.       <title>Reconstructing the Person Class</title>
  5.       <link type='text/css' rel='stylesheet' href='style.css'/>
  6.     </head>
  7.     <body>
  8.       <p>
  9.         <!-- Your code here -->
  10. <?php
  11.         class Person {
  12.             public $isAlive = true;
  13.             public $firstname;
  14.             public $lastname;
  15.             public $age;
  16.  
  17.         // public function _contstruct    You can do it!
  18.  
  19.             public function __construct($firstname, $lastname, $age) {
  20.                 $this->firstname = $firstname;    
  21.                 $this->lastname = $lastname;
  22.                 $this->age = $age;
  23.                 }
  24.         }
  25.             $teacher = new Person("boring","12345",12345);
  26.             $student = new Person("Stud","Nenti",19);
  27.             echo $teacher->isAlive;
  28.             echo $student->age;
  29.         ?>
  30.       </p>
  31.     </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement