Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Return Variables With PHP

With PHP, you can return one variable or an array from a function. The example below explains how to retun a single variable.

function add_numbers($number_one,$number_two){
    $mytotal = $number_one + $number_two;
    echo $mytotal;
    return $mytotal;
}

$num1 = “1”;
$num2 = “2”;

//The function will make variable called $mytotal which can be returned from the function
$total = add_numbers($num1,$num2);
echo “<br/><br/>”;

//$total is setting the variable equal to the function
//The value $mytotal is returned and is printed below
echo “The total $total is returned from the function which can only return a single variable or array. In this case, the function returns a variable.”;