Using Output Buffer Is It Allowed ?

I’m working on a wordpress theme, I have reach a point that i need one file to act differently based on the current page and the settings for this page, these settings are hold into variables and some of these variables are in usage before defining them. for example:
echo $_var1; $_var1 = test;

so my solution was the output buffer because I just want to include this file in all the pages and leave the job for it without creating a class or function.

any one here faced a similar situation ?