<html> <head> <title>A Class with a Constructor</title> </head> <body> <?php class first_class{ var $name; function first_class( $n="default name" ){ $this->name = $n; } function sayHello(){ print "my name is $this->name<BR>"; } } $obj1 = new first_class("object 1"); $obj2 = new first_class("object 2");
$obj1->sayHello(); $obj2->sayHello();
?> </body> </html>
_________________ M. S. Rakha, Ph.D. Queen's University Canada