Posted by Windcape Thu 1st Mar 2007 05:25 - Syntax is PHP - 20 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers
PHP parser reported no syntax errors in this post!
  1.  
  2. class Person
  3. {
  4.     private $firstName;
  5.     private $lastName;
  6.     private $age;
  7.     private $sex;
  8.  
  9.     public function __construct($firstName,$lastName,$age,$sex) {
  10.         $this->firstName = $firstName;
  11.         $this->lastName  = $lastName;
  12.         $this->age = (int)$age;
  13.         $this->sex = $sex;
  14.     }
  15.  
  16.     public function getYearOfBirth() {
  17.         $today = (int)date("Y"); // 2007
  18.         return $today - $this->age;
  19.     }
  20.  
  21. }
  22.  
  23. $person = new Person('Claus','Joergensen',20,'male');
  24. echo $person->getYearOfBirth(); // 1987 ... okay, a bit wrong :) I'm from '86
  25.  
  26. ?>

PermaLink to this entry https://pastebin.co.uk/11198
Posted by Windcape Thu 1st Mar 2007 05:25 - Syntax is PHP - 20 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers

 

Comments: 0