Jump to content

Meta refresh vs. header()


TecBrat

Recommended Posts

I have found many occasions where I want to use an existing script inside one of my pages. If I have html content before the script starts, I have run into problems because the scripts use something like

header('Location: ' . $url);

and I get header already sent errors.

I found that I can replace that code with

?><meta http-equiv="refresh" content="0; url=<?echo($url);?>"><?

and it works. The last time I used it, I could actually see the refresh even though the content is set to zero, but that's not too big a deal.

 

I was wondering if anyone could tell me what, if anything, I might expect for problems caused by this change.

Link to comment
https://forums.phpfreaks.com/topic/44875-meta-refresh-vs-header/
Share on other sites

Be sure you use the header before you do anything. With meta tag, the user will first receive the page and that the browser redirects. Same for javascript though. I use javascript (although I hate that language) to redirect a user when the page is already (partly) loaded. But use the header if possible.

 

Full-Demon

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.