You need to set the variable BEFORE you do the include. An include effectively just pastes the code into the place where you have the include statement. If you change a variable after the include, it has no effect.
$variable = "Something";
include ("header.php");
$variable = "Something else";
include ("footer.php");