PHP program to demonstrate the default or no-argument constructor

bookmark

<?php  
    //PHP program to demonstrate the 
    //default or no-argument constructor
    class Sample
    {  
        public function  Sample()
        {  
            echo "Default constructor called<br>";  
        }  
        public function  Method1()
        {  
            echo "Method1 called<br>";  
        }  
    }  
    $S = new Sample();  
    $S->Method1();
?>


Output
Default constructor called
Method1 called