How can ternary operators be used in PHP to create a custom function for handling null values?

When working with PHP, handling null values can be a common task. One way to handle null values in a custom function is by using ternary operators. Ternary operators allow you to check if a value is null and provide a default value if it is. This can help streamline your code and make it more readable.

function handleNullValue($value) {
    $result = $value ?? 'Default Value';
    return $result;
}

// Example usage
echo handleNullValue(null); // Output: Default Value
echo handleNullValue('Hello'); // Output: Hello