$userinfo['username'] is proper, because 'username' (string) is key in the $userinfo array. The first one would be correct if username was a constant, or if its being parsed within double quotes (which templates are).
PHP Code:
echo $userinfo['username']; // correct
echo $userinfo[username]; // incorrect [issues notice of unknown constant]
echo "$userinfo['uesrname']"; // parse error
echo "$userinfo[username]"; // correct, but a tad slower than example 1