What best practices should be followed when incorporating IF statements within an echo statement in PHP?

When incorporating IF statements within an echo statement in PHP, it is important to ensure proper syntax and readability. To achieve this, it is recommended to break out of the echo statement to include the IF condition separately, and then concatenate the result within the echo statement. This approach helps maintain code clarity and makes it easier to debug if needed.

<?php

// Example of incorporating IF statements within an echo statement in PHP
$var = 10;

// Break out of the echo statement to include the IF condition separately
if($var > 5) {
    $message = "Variable is greater than 5.";
} else {
    $message = "Variable is not greater than 5.";
}

// Concatenate the result within the echo statement
echo "Result: " . $message;

?>