user198729
user198729

Reputation: 63626

When do header(..) statements take effect in PHP?

  1. after all stuff behind is run
  2. immediately

Which is the case? Can anyone verify this?

Upvotes: 1

Views: 171

Answers (5)

kevinverhoef
kevinverhoef

Reputation: 64

To make sure that a page is directly redirected, add a exit; after the header.

Upvotes: 1

rekha_sri
rekha_sri

Reputation: 2725

Refer the following link.

http://php.net/manual/en/function.header.php

Upvotes: 1

Javier
Javier

Reputation: 4623

Depends on output buffering, but the PHP interpreter still only uses them after having interpreted all the code before, just like a normal function. Still, there must not be any HTML before a header(), or things will screw up.

Upvotes: 0

Dolbz
Dolbz

Reputation: 2106

If output buffering is disabled then it will be sent immediately. It must be sent before any other content (however you can perform processing logic before sending the header)

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157839

depends on the output_buffering setting
headers_sent() function can verify

Upvotes: 0

Related Questions