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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.