Difference between revisions of "PHP:Define a Class"

From Progzoo
Jump to: navigation, search
Line 5: Line 5:
 
*attributes <code>n, w</code> and <code>h</code>  
 
*attributes <code>n, w</code> and <code>h</code>  
 
*a method: <code>bmi</code>
 
*a method: <code>bmi</code>
<prog> class Person {
+
<prog>
 +
<?
 +
class Person {
 
   public $name;
 
   public $name;
 
   private $weight, $height;
 
   private $weight, $height;
Line 19: Line 21:
 
     return $bmi;
 
     return $bmi;
 
   }
 
   }
}
+
}
  
 
  $p = new Person("andrew",99,1.8);
 
  $p = new Person("andrew",99,1.8);
 
  echo ($p->bmi());
 
  echo ($p->bmi());
 
  echo ($p->n);
 
  echo ($p->n);
 +
?>
 
</prog>
 
</prog>
 
</question>
 
</question>

Revision as of 15:24, 12 February 2009

Line: 123 DOMDocument::loadXML(): xmlParsePI : no target name in Entity, line: 7