$user_id = 123; $profile = getUserProfile($user_id); echo "User name: " . $profile['name']; echo "User email: " . $profile['email'];
$user_id = $_SESSION['user_id']; $profile = getUserProfile($user_id); if ($profile['is_admin']) { echo "Welcome back administrator!"; } else { echo "Welcome back " . $profile['name'] . "!"; }This example retrieves the user ID from the session and uses it to retrieve the user profile. It then checks whether the user is an administrator and displays a different message depending on whether they are an admin or not. The function `getUserProfile` is likely to be part of a larger package or library that provides functionality for handling user profiles. Possible packages or libraries include user management systems, social networking APIs, or content management systems. Overall, the getProfile function in PHP is a useful method for retrieving user profile information in web applications.