What potential issue can arise when using if/else statements in PHP, especially when incorporating templates?

When using if/else statements in PHP, especially when incorporating templates, a potential issue that may arise is the cluttering of the template with conditional logic. To solve this issue, you can move the conditional logic to the PHP code before rendering the template, and then pass the result as a variable to the template.

<?php
// Sample PHP code with if/else logic
$loggedIn = true;

// Move the conditional logic outside of the template
if($loggedIn) {
    $message = "Welcome, User!";
} else {
    $message = "Please log in to access this page.";
}

// Pass the result as a variable to the template
$templateData = [
    'message' => $message
];

// Render the template
// include 'template.php';
?>