How does the ternary operator work in PHP, and how is it used in the given code snippet?

Issue: The ternary operator in PHP is a shorthand way of writing an if-else statement. It is used to assign a value to a variable based on a condition. In the given code snippet, the ternary operator can be used to simplify the if-else statement and make the code more concise. Code snippet with ternary operator implementation:

// Original code snippet
$score = 85;
$grade = '';

if ($score >= 60) {
    $grade = 'Pass';
} else {
    $grade = 'Fail';
}

// Using ternary operator
$grade = ($score >= 60) ? 'Pass' : 'Fail';