pbrama;10987210 wrote:In other web languages, such as ASP, when you call a line of code to change to a new page
That's not true. You can't "change to a new page" in ASP because you are the server, not the client. The client is the one who requests pages. Therefore, all you can do is redirect the client to the new page (e.g. tell the client to make a new request for a different page).
pbrama;10987210 wrote:I "thought" the similar command was a
header('locations url');
Well the syntax for the HTTP header is "Location: <full URI>", but yes, that is the same result as the ASP redirect (e.g. Response.Redirect) that you referred to above.
pbrama;10987210 wrote:The first is WHERE in the code it is called... that it needs to be before certain things and only if there was not some other HEADER call.
That's entirely false. It isn't "certain things" that it must come before - it's "any output". In other words, once you send any output (either via echo/print in PHP or any text outside of <?php .. ?> that gets sent as output).
You can also call [man]header/man an arbitrary number of times before output (i.e. the second part of your statement above is entirely false).
pbrama;10987210 wrote:The second was that unless you put an EXIT; following it, the page you are on still runs... somewhere.
What do you mean "somewhere" ? It runs in the same place all other PHP code runs - on the server. When the client makes a request for a PHP page, the server executes the PHP script, relaying the output of that script on to the client as it is generated.
Simply queuing up an HTTP header to be sent by the server doesn't change any of that - the PHP script is still going to continue executing until it has finished.
pbrama;10987210 wrote:Doing some looking around the web, although the HEADER call is often used, there seems to be alot of indecisiveness about it.
Indecisiveness about.. what?
pbrama;10987210 wrote:I also read, a couple post that recommended calling a JAVASCRIPT call to actually do the page change instead.
Did they also recommend not sailing too far across the ocean before you fall off the edge of the world? Earth is flat, after all...
(In other words, that's a bad recommendation. 😉)
pbrama;10987210 wrote:what is the preferred or ideal method FOR changing pages programmatically
What do you mean "changing pages" ? If you mean informing the client that it should request a different URL to complete its request, then use [man]header/man to send the appropriate HTTP header (such as a 'Location' header).
pbrama;10987210 wrote:keeping in mind, it could be further in the code than the very top.
Doesn't matter - just perform all of the logic you need in order to determine if a redirect is necessary before you output anything. (This should be common sense; why waste time generating output if it's just going to be ignored due to a redirect?)