$current_user = currentMember(); $username = $current_user->Username; echo "Welcome, $username!";
$current_user = currentMember(); if ($current_user){ // User is logged in echo "Welcome, {$current_user->Username}!"; } else { // User is not logged in echo "Please log in to access this page."; }In this example, we use the currentMember function to check if the user is logged in. If they are, we output a personalized greeting message. If not, we prompt them to log in. The PHP Member currentMember function is part of the SilverStripe CMS, a popular open-source content management system (CMS) built using PHP.