How to use return value and parameters in php functions


We will show you a simple example for the parameters and the return value . Return value is used to get the result of the function in the variable. Return is the key word which is needed to return the value out side the function.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Functions with return value Examples in PHP</title>
// A simple example with out the parameters

function login()
//You can write what ever you want to write in the function
return 'Welcome User X.';
$status&nbsp; = login();
echo $status;

//Function with the return value and the parameters.
//We will calculate the string lenght and then return the lenght value
function calculate($val)
$v = strlen($val);
return $v;
$total = calculate('My Name is John');

echo 'Lenght of the String is -'.$total;