Edit: Solved by reading BETTER the answer from mario at How to fix "Headers already sent" error in PHP. Adding an ob_start() at the beginning of my file solved my issues.
Recently I figured out a very strange behavior in php: when certain lines of javascript are present php throws "Cannot modify header information - headers already sent..." error.
I read tons of posts saying it is impossible to modify header information with header() function, but I always been able to!
The code is:
if(this.innerHTML == "menu"){
document.getElementById("side_panel").style.left = "0px";
document.getElementById("side_panel").style.paddingLeft = "5vw";
this.style.opacity = "0";
setTimeout(function(){document.getElementById("nav_button").innerHTML = "close";document.getElementById("nav_button").style.opacity = "1"},200);
}
else {
document.getElementById("side_panel").style.left = "-250px";
document.getElementById("side_panel").style.paddingLeft = "0vw";
this.style.opacity = "0";
setTimeout(function(){document.getElementById("nav_button").innerHTML = "menu";document.getElementById("nav_button").style.opacity = "1"},200);
}
It works when I keep only:
if(this.innerHTML == "menu"){}
Just adding this:
if(this.innerHTML == "menu"){
}
else{
}
Make php throw the error.
Please help me, I'm hopeless. Thank you all for your amazing work.