How can functions in PHP return values to the calling code?
Functions in PHP can return values to the calling code using the `return` statement. When a function is called and it reaches a `return` statement, the function will stop executing and return the specified value to the calling code. This allows functions to pass data back to the code that called them, enabling the reuse of values calculated or processed within the function.
function calculateSum($num1, $num2) {
$sum = $num1 + $num2;
return $sum;
}
$result = calculateSum(5, 3);
echo $result; // Output: 8