How can PHP's if-else statements be utilized to control user access to specific pages based on profile information?

To control user access to specific pages based on profile information using PHP's if-else statements, you can check the user's profile information (such as their role or permissions) and then use conditional statements to determine whether they should be allowed to access a particular page or not.

<?php
// Assume $userProfile is an array containing the user's profile information

if ($userProfile['role'] == 'admin') {
    // Allow admin users to access the page
    include 'admin_page.php';
} elseif ($userProfile['role'] == 'editor') {
    // Allow editor users to access the page
    include 'editor_page.php';
} else {
    // Redirect other users to a different page or display an error message
    header('Location: unauthorized_access.php');
    exit;
}
?>