Lets start with the basics here, you _cannot_ write php into the vBulletin templates, period.
I said you might want to checkout the plugin system, as in see how it works, chances are it will work for you.
All you have to do is write your php code
PHP Code:
$test = "Hello $vbulletin->userinfo[username]"
Into a plugin like global start, then in the header template you could put $test and it will display.