Difference between revisions of "PHP:Define a Class"

From Progzoo
Jump to: navigation, search
Line 24: Line 24:
  
 
   $p = new Person("andrew",99,1.8);
 
   $p = new Person("andrew",99,1.8);
   echo ($p->bmi()."\n");
+
   print ($p->bmi()."\n");
   echo ($p->name);
+
   print ($p->name);
 
?>
 
?>
 
]]></prog>
 
]]></prog>
 
</question>
 
</question>

Revision as of 16:45, 13 February 2009

The class Person has

  • a constructor: __construct
  • attributes name, weight and height
  • a method: bmi


[Font] [Default] [Show] [Resize] [History] [Profile]