PHP : Function

/* user-defined fucntion */
function test(){
echo "hello world";
}



/* calling user-defined fucntion */
test();
//output hello world

/* returning values */
function add()
{
return 1 + 1;
}

add();
//output 2
/* passing variable to functions */
function test($string)
{
          echo "hello ".$string;
}

test('world');
//output hello world



/* returning values */
function add($number)
{
         return 1 + $number;
}

add(1);
//output 2

0 comments: