<p>To display the name of a registered user, use this instead:</p>
<pre>
global $user;
if ($user->uid) {
  print t('Welcome @name! Thank you for visiting.', array('@name' => $user->name));
}
else {
  print t('Welcome visitor! Thank you for visiting.');
}
</pre>