Re: [PHP4BETA] Header() in PHP4

From: Date: Wed, 25 Aug 1999 06:10:24 +0000
Subject: Re: [PHP4BETA] Header() in PHP4
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-3703@lists.php.net to get a copy of this message
Mitch Vincent wrote: > > So use a HTML meta tag : > > echo "<meta http-equiv=\"Refresh\" content=\"0; > url=http://whatever\">"; > > The "0" there is the time it takes to refresh in seconds I believe, 0 is an > immediate redirect (actually there is a very small delay). I use it all the > time, works like a charm. I am aware of this tag, but it's that small delay that I am looking to avoid. > > As far as the CF - PHP argument, I've seen nothing done in CF that couldn't > be done in PHP and vice versa, That's not true there's things PHP can do that CF can't. :-) I'm sure there are such things, but I'm not > sure what they would be (if anyone knows or has examples, please send them > to me, I'm curious).. This is one thing and I just sent the example. > -----Original Message----- > From: Michael Stearne <MStearne@eisolutions.com> > To: php4beta@lists.php.net <php4beta@lists.php.net> > Date: Tuesday, August 24, 1999 6:10 PM > Subject: [PHP4BETA] Header() in PHP4 > > >People ask about the differences between PHP and Cold Fusion regularly. > >One thing that I liked about Cold Fusion was the CFLOCATION tag, which > >is works like the header() tag in PHP. > >One big difference between the CFLOCATION and header is that it is > >possible to have HTML and output on a page before the tag is called. For > >example (I am unsure of CF syntax): > > > ><HTML> > ><body> > >This is something > > > ><CFIF #VAR# is 3> > ><CFLOCATION location="page.html"> > ></CFIF> > > > ></body> > ></html> > > > >Whereas PHP requires: > > > ><? > >if($var==3) > >header("Location: page.html") > >?> > ><html>.... > > > >Either way is easy to use, but there is sometimes an advantage in > >running some output before the page is redirected. I know this can be > >done with a <META> tag, but I don't like the fact that the user can hit > >Stop on the browser. > > > >The reason why I am asking about this feature in PHP4 is because I > >(maybe wrong) am under the impression the script is "compiled" > >completely before output is sent to the browser. I don't believe this > >was the case with 3. And I believe this is the way CF works. > > > >Sooo, is there anyway that this functionality can be added to version > >4. This would also be a valuable feature for the SetCookie function. I > >don't always have the opportunity to set a cookie before any output has > >been sent consequently I use a function JSSetCookie(below) which works > >like SetCookie but prints Javascript out for the browser to pick up on. > >But that requires the user to have JS on. > > > > > >Any thoughts? > >Michael Stearne > > > >--------------------------------------------------------------------------- > ---- > > > >function JSSetCookie($CName,$CValue,$CExpr=FALSE){ > >// $CXpr is in years > >// Will allow cookies to be set even after HTML has been printed on the > >page > >if($CExpr!=FALSE){ > >$CookieString="astr= '$CName' + '=' + '$CValue' + > >';expires=' + expr + > >';path=/';"; > >$Cookie.="\n<script language=\"javascript\">\n"; > >$Cookie.='function makeYearExpDate(yr){ > >var expire = new Date(); > >expire.setTime(expire.getTime() + ((yr *365) *24 * 60 * 60 * 1000)); > >expire = expire.toGMTString() > >return expire > >} > >expr =makeYearExpDate('.$CExpr.');'; > >$Cookie.="\n".$CookieString."\n"; > >$Cookie.="document.cookie=astr;\n</script>\n"; > >}else{ > >//$CookieString="astr= '$CName' + '=' + '$CValue' + > >';expires=;path=/';"; > >$Cookie.="\n<script language=\"javascript\">\n"; > >$Cookie.="document.cookie='$CName=$CValue;path=/';"; > >$Cookie.="\n</script>\n"; > >} > >echo $Cookie; > >} > > > >-- > >PHP 4 Beta > > > > > > -- > PHP 4 Beta

« previous php.version4 (#3703) next »