How can PHP be used to differentiate between admin and user functions on a website?

To differentiate between admin and user functions on a website using PHP, you can create a session variable upon login that stores the user's role (admin or user). Then, you can check this session variable on each page where admin-specific functionality is required.

// Upon successful login, set the user's role in a session variable
$_SESSION['role'] = 'admin'; // or 'user'

// Check the user's role on each page where admin-specific functionality is required
if($_SESSION['role'] == 'admin'){
    // Admin-specific functionality here
} else {
    // User-specific functionality here
}