How can the comparison operator (==) be correctly used in the if statement in the PHP code snippet to ensure proper functionality?

When using the comparison operator (==) in an if statement in PHP, it is important to ensure that the comparison is done correctly to avoid unexpected behavior. To compare two values for equality, the double equals (==) operator should be used instead of a single equals sign (=), which is used for assignment. This will ensure that the if statement evaluates the comparison correctly and executes the corresponding code block based on the comparison result.

// Example PHP code snippet with correct usage of the comparison operator (==) in an if statement

$value1 = 10;
$value2 = 5;

if ($value1 == $value2) {
    echo "The values are equal.";
} else {
    echo "The values are not equal.";
}