PHP program to define methods within the class

bookmark

<?php
//PHP program to define methods within the class.
class Sample
{
    //Methods
    function Method1()
    {
        print ("Method1() called" . '<br>');
    }
    function Method2()
    {
        print ("Method2() called" . '<br>');
    }
}

$S = new Sample();

$S->Method1();
$S->Method2();
?>


Output
Method1() called
Method2() called