Why is the "return" statement used in PHP functions if variables are not automatically made global?

The "return" statement is used in PHP functions to explicitly specify the value that should be returned from the function. This allows the function to pass data back to the calling code, even if variables are not automatically made global. By using the "return" statement, you can control what data is passed back from the function, making it a flexible and powerful tool for building reusable code.

function addNumbers($num1, $num2) {
    $sum = $num1 + $num2;
    return $sum;
}

$result = addNumbers(5, 3);
echo $result; // Output: 8