I now recall that ColdFusion's location tag accepts no data parameters, so you can't pass data to it. It is essentially a redirect. Thus, it may be doing an HTTP header location under the hood.
In ColdFusion, I may have logic like so: ------------------------- <cfset num=0> <!-- whitespace --> <cfif (num = 1)> OK! <cfelse> <location url="gohere.cfm"> </cfif> I don't get any errors, so I think it buffers the entire output first and then throws away if it determines if it needs to go elsewhere. In PHP, it would look something like this: ---------------------------------------- <?php num = 0; ?> <!-- whitespace --> <?php if (num = 1) { header("location: gohere.php"); } ?> This will not run, because of the whitespace. I presume PHP immediately begins the http/html stream as soon as it sees non-php code. In ColdFusion, it doesn't care about the whitespace. In PHP, it does care about the whitespace. That is what I discovered in my original problem. I had a whitespace between the php identifiers. I simply closed off the whitespace, and I was fine. Thanks for clarifying all this. Sincerely, Stephen ----- Original Message ----- From: "Rasmus Lerdorf" <[EMAIL PROTECTED]> To: "webapprentice" <[EMAIL PROTECTED]> Cc: "James" <[EMAIL PROTECTED]>; "Jason Murray" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 12:24 AM Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag? > > Hi Mr. Lerdorf, > > I look forward to you upcoming O'Reilly PHP book. =) > > > > Yes, a META tag refresh or Javascript control seems to be the only way left. > > Strange that URL redirection is so unusual to implement in PHP compared to > > ASP or Coldfusion (unless they do something klunky under the hood). > > They do. There is no magic here. If you want output on a page and also do > a redirect, the only way to do it is with a javascript meta-refresh (well, > you can do some tricks with frames as well, but I lump those tricks under > Javascript redirects). I don't care what ASP of Cold Fusion tells you, if > they allow you to send some data for the page and then redirect, then they > are either doing a Javascript meta-refresh or simply tossing your data and > doing a Location redirect. > > If you have no output, then you can use a Location redirect. What ASP and > Cond Fusion might do is buffer your output and simply throw it away if you > then at some point do a Location redirect. That seems kind of silly to me > though. It seems like a mistake to me to just chuck away output data like > that. You can do that with PHP as well by turning on output buffering. > You can send all sorts of output after a Location redirect, but there will > be no browser around to see it because it has already received the > Location redirect and is off viewing the other page. > > > Anyway, I also noticed that when the manual says you cannot output ANYTHING, > > I found out that if I close out all my spaces in the PHP page by tightening > > the php container tags, I will not output anything first. I forgot that > > even whitespace would be considered a web page and would generate http > > headers (since the PHP processor probably translates whitespace as > > echo/print statements). > > Yup, a space is as valid a character as any other. > > -Rasmus > > PS. One of the things with PHP is that we have never gone out of our way > to hide the actual mechanics of HTTP very much from the users. I think it > is important for people to actually understand what is going on. That's > why we don't have a redirect() function but instead tell you to send an > HTTP header called Location. Because that is what needs to happen under > the covers. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php