What is the best practice for implementing a function in PHP that returns the content if set and an empty string if not set?

When implementing a function in PHP that returns content if set and an empty string if not set, the best practice is to use the null coalescing operator (`??`) to check if the variable is set or not. This allows for a concise and readable way to handle the logic without needing to write lengthy if-else statements.

function getContent($content) {
    return $content ?? '';
}

// Example usage
$myContent = 'Hello, World!';
echo getContent($myContent); // Output: Hello, World!

$myContent = null;
echo getContent($myContent); // Output: ''