How can conditional statements in PHP be used to control the appearance of HTML elements?

Conditional statements in PHP can be used to control the appearance of HTML elements by evaluating a condition and displaying different HTML code based on the result. For example, you can use an if statement to check a condition and display a specific HTML element if the condition is true, or an else statement to display a different element if the condition is false.

<?php
$loggedIn = true;

if ($loggedIn) {
    echo '<p>Welcome, user!</p>';
} else {
    echo '<p>Please log in to access this content.</p>';
}
?>