Sunday, February 27, 2011

Create-new-function-PHP (Part 3)

Assalamu'alaikum and selamat sejahtera

For this post,we will learn on how to past the variable that declared that outside the function to the our function,than that function will process it and come out with output.Here is the example:


<?PHP
 
$display_text = "Variable message";
display_message($display_text);

function display_message($display_text) {
print $display_text;
}


?>

or how about we apply some mathmatic:


<?PHP
$number = 2;
display_math($number);

function display_math($number) 
{
$number=$number+4;
print $number;
}

?>

it print 2 or 4 or 6?so,i leave that answer to you. How about you just try to create a function that can accept multiple variable.Here is the example of function that can accept more than one variable::

function display_subtraction($number1,$number2)

try it!




N/NOTE:any problem?just comment here ^^

No comments:

Post a Comment