Monday, December 31, 2012

Create a simple addition function in PHP

<?php
    //decleartion of a function
    function addition($x,$y){
        $res = $x + $y;
        return $res;
    }
    $x = 4; //initializing the variable x
    $y = 7; //initializing the variable y;
    $res = addition($x,$y); //holding the result
    echo 'The addtion of x and y is: '.$res; //printing the addition result;
?>

No comments:

Post a Comment