I think you wil find this is a big homer's DOH!
passthru's description in the manual:
-- quote --
passthru -- Execute an external program and display raw output
Description
void passthru (string command [, int return_var])
-- end quote --
in short, it prints everything to screen, and returns absolutely nothing.
That's why strlen($userinfo) returns 0: $userinfo really IS empty.
try using backticks instead of passthru:
$command = "/usr/bin/finger -lpm ". escapeshellarg($username) . " | grep Name";
$userinfo = $command;