Create Class instance : Class Instance « Class « PHP






Create Class instance

<?php
class ClassName{
   var $var1;
   var $var2;
  
   function myfunction1(){
      $result = "$this->var1 and $this->var2";
      return $result;
   }
  
   function myfunction2(){
      $myfunction1 = $this->myfunction1();
      return $myfunction1;
   }
}

$myclass = &new ClassName;

$myclass->var1 = "A";
$myclass->var2 = "B";

echo $myclass->myfunction1()."<br />";
echo $myclass->myfunction2()."<br />";
?>

           
       








Related examples in the same category