What are the potential pitfalls of not passing variables properly to PHP functions, as seen in the provided code snippet?

The potential pitfall of not passing variables properly to PHP functions is that the function may not receive the expected data type or value, leading to errors or unexpected behavior in the code. To solve this issue, make sure to pass the variables correctly as arguments to the function with the correct data type.

// Incorrect way of passing variables to a function
$number1 = "10";
$number2 = "20";

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

// Correct way of passing variables to a function
$number1 = 10;
$number2 = 20;

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

echo addNumbers($number1, $number2); // Output: 30