On 15 July 2010 16:38, Carlos Sura <carlos_s...@hotmail.com> wrote:
> Hello mates, I'm developing a user registration and access level system...
> And I wonder... Is there any way to avoid to put code in every header page?
> Because, almost every page contains javascript, so almost every page cotains 
> <html> tags... And its annoying to look at this: Warning: session_start(): 
> Cannot send session cache limiter - headers already sent
> So, I'm wondering, is there any other way to avoid put code in every page? 
> or... another way to avoid that kind of error.

The quick and dirty way is to use output buffering - [1].

The better way is to use includes/requires - [2]. This will involve
moving code around the system, extracting common parts and then
"include"-ing them in the right place.

Also, a common practise is to only have output generated at the end of
the script, rather than using a lot of echo's through out the code. A
sort of manual output buffering.


Richard Quadling.

[1] http://docs.php.net/manual/en/book.outcontrol.php
[2] http://docs.php.net/manual/en/language.control-structures.php and
look for include/require/include_once/require_once

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to