Instead of using variable, you can use `return`:
```php
if (!function_exists('json_last_error_msg')) {
    switch (json_last_error()) {
        default:
            return 'Unknown error';
    }
}

return json_last_error_msg();
```