You need to use advance theme and override header() function and place any php code you want to add. Something below
//here your php code..
but make sure in this case your php code will start right after default header code so you need to work out to get the result you want. But method would be the same.