Difference between revisions of "PHP:Define a Class"

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

Revision as of 16:43, 13 February 2009

The class Person has

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


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