How can error handling be incorporated into PHP functions to provide meaningful feedback to users in case of incorrect input?

When creating PHP functions, it's important to incorporate error handling to provide meaningful feedback to users in case of incorrect input. This can be achieved by using conditional statements to check the input parameters and return appropriate error messages if the input is invalid.

function calculateArea($length, $width) {
    if (!is_numeric($length) || !is_numeric($width)) {
        return "Error: Please enter valid numeric values for length and width.";
    }

    $area = $length * $width;
    return $area;
}

// Example usage
$length = "abc";
$width = 5;
echo calculateArea($length, $width);