How can the correct syntax for an If statement in PHP be ensured to effectively hide or show elements in a web page?

To ensure the correct syntax for an If statement in PHP to effectively hide or show elements on a web page, you need to properly structure the condition within the if statement. Make sure to use the correct comparison operators and logical conditions to evaluate whether an element should be hidden or shown based on certain criteria. Additionally, ensure that the PHP code is embedded within the HTML markup where the elements are located.

<?php
// Example condition to hide or show an element based on a variable value
$showElement = true;

if ($showElement) {
    echo '<div>This element is shown</div>';
} else {
    echo '<div style="display: none;">This element is hidden</div>';
}
?>