PHP Functions

, by Prashant Gunjal

Program :

<html>
<head>
    <title>PHP Functions</title>
</head>
<body>
<?php
    $no1=10;
    $no2=20;
    function display()
    {
        echo "<br> Hii now we will se the functions";
    }

    //Parameterless function
    function add()
    {
        $a1=5;
        $a2=6;
        $result=$a1+$a2;
        echo "<br>Addition is = $result";
    }

    //Parameterised function
    function sub($a1,$a2)
    {
        $res=$a1-$a2;
        echo "<br>Substraction is = $res";
    }

    //returning function
    function mul($a1,$a2)
    {
        $res=$a1*$a2;
        return $res;
    }
   
    //function calling
    display();
    add();
    sub($no1,$no2);
    $res_new=mul($no1,$no2);
    echo "<br>Multiplication is = $res_new";
?>
</body>
</html>

OUTPUT :


0 comments: