Those are vb template if conditionals that can't be used in your PHP file.
Your PHP FILE is executed AS IS (outside of vBulletin's everything) and its output is assigned to your variable.
You don't even need a plugin for this, just plop your code into the header template. I'd change $thread to $GLOBALS though instead.
If you were going to do it in php, you'd need to do a bunch of stuff to get into vBulletin, and then you'd have to do some php:
PHP Code:
if ($foo == bar) {echo "something stupid";}
But you're not inside of the scope of vBulletin, so you can't use vBulletin variables