How can the return statement be used effectively in PHP functions to ensure proper variable access?

When using the return statement in PHP functions, it is important to ensure that the value being returned is assigned to a variable outside of the function to access it properly. This can be done by calling the function and storing the returned value in a variable. By doing this, the value can be used in other parts of the code or passed as an argument to other functions.

function calculateSum($num1, $num2) {
    return $num1 + $num2;
}

$sum = calculateSum(5, 3);
echo $sum; // Output: 8