You've answered your won question why you cant use <?PHP?> tags in the template, is beacause YaBB parses the template, not PHP.
PHP parses YaBB to parse the template.
Anyway Joseph explained it:
QuoteA final note is that the function captures the output of your program - not the return value. So all you need to do is print or echo what you want to display - and it'll be captured and inserted at the right spot.
so you have your own script, say your own poll, and all u have to do is just a print(), echo() for variables or a require(), require_once(), include() you know them all use the right one.