Loading, please wait...

A to Z Full Forms and Acronyms

How to define methods within the class in PHP | PHP program

Jan 18, 2022 PHP, 919 Views
How to define methods within the class in PHP | PHP program

How to define methods within the class in PHP | PHP program

We will define a class Sample class with two methods within the class.

<?php

class Sample
{

    function Method1()
    {
        print ("Method1() called" . '<br>');
    }
    function Method2()
    {
        print ("Method2() called" . '<br>');
    }
}

$S = new Sample();

$S->Method1();
$S->Method2();
?>
A to Z Full Forms and Acronyms