PHP:Define a Class

From Progzoo
Revision as of 14:59, 12 February 2009 by 08011145 (talk | contribs) (New page: class Person { public $name; private $weight, $height; public function __construct($name, $weight, $height) { this->name = $name; this->weight = $weight; this->height =...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

class Person {

 public $name;
 private $weight, $height;
 public function __construct($name, $weight, $height)
 {
   this->name = $name;
   this->weight = $weight;
   this->height = $height;
 }
 public function bmi()
 {
   $bmi = $this->weight / $this->height / $this->height;
   return $bmi;
 }

}

public class Hello {

 public static void main(String argv[])
 {
   $p = new Person("andrew",99,1.8);
   Echo ($p->bmi());
   Echo ($p->n);
 }

}