The ID of the user whose username is being retrieved
Description of Returned Data
Returns a string, which is the username fetched from the database table 'users' based on the provided user ID. If the user ID does not exist, it returns a dash ("-").
The name_from_id function is a helper function in UserSpice that takes in a user ID and returns the username associated with that ID. If the ID is not found in the database, it returns a dash (-) as a placeholder.
If the user is found in the database, the function returns the username associated with the $id parameter, with the first letter capitalized (using the ucfirst function).
If the user is not found in the database, the function returns a dash (-).
$user_id = 42; $user_name = name_from_id($user_id);
echo "The username associated with ID $user_id is $user_name.";