替换模具声明

Currently my code looks like this

<?php
if($controlSomething) {
    include(header);
    echo "something";
    include(footer);
    die();
}

if($anotherControl) {
    include(header);
    doSomeOperations(); // would throw an error if $controlSometing is true
    echo "something else";
    include(footer);
    die();
}
?>

Clearly this is not a good way to do things. I want to move to something cleaner.

I created a view class to wrap the page and avoid the include(header)/include(footer) repetition. I also converted all the conditional statement, changing if($condition) into function condition ().

Now what should I do ? I was thinking of something like this :

if(condition1()) { message for condition1 ...}
else if(condition2()) {}

The problem is that this file might be included by another file that will be executed because there is no die statement anymore.

So should I include a var like "Die" in the view object and check its value before doing anything on every page ? This doesn't seem clean to me. I have thousands of lines of code like this so the more simple/automated the solution, the better.