A Class with a Constructor : Class Constructor : Class PHP Source Code


PHP Source Code » Class » Class Constructor »

 

A Class with a Constructor



<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>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Class Constructor