Re: HTTP headers and include()

From: Date: Fri, 24 Aug 2001 23:41:58 +0000
Subject: Re: HTTP headers and include()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64360@lists.php.net to get a copy of this message
Get rid of the trailing newline after your last ?> in slib.php Warning: You may have configured Emacs to "add" that newline in for you automatically. Turn that off, if so. Never have understood why: <?php ... ?> <?php ... ?> Doesn't generate HTML output, except when ?> is the end of the file... -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Casteele/Shadowlord <casteele@innocent.com> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Wednesday, August 22, 2001 10:52 AM Subject: HTTP headers and include() > I've written a separate function library for a cluster of web pages, and I > then include("slib.php") in each of the web pages, instead of copying 12k > of code to each page individually. Some of the pages require (simple) > authentication or redirection headers, which some of the code in the > library is supposed to handle. > > Problem is, when I include the library, even though there's no other output > to be processed, it still generates the linefeed that triggers sending all > the current headers, so if(!headers_sent) {...} fails. > > Is it possible to include php code without sending headers? I've tried > exit() within the library, but that fails to work. Instead, exit causes > generation of HTML code (a content type metatag) that is neither in the > main page nor the library. I've also tried a simple return() (per the > documentation), but that generates a parse error. > > I'm using Apache 1.3.12, PHP 4.0.2 and Slackware Linux (Not sure which > kernel version). > > Thanks > Cas > > PS: Please CC replies to casteele@innocent.com, since I'm not officially > subscribed to this list. Thanks. >

« previous php.general (#64360) next »