Including a php file getting error ( 1007: Cannot modify...)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thomas49th
Forum Newbie
Posts: 11
Joined: Wed Aug 04, 2010 4:29 pm

Including a php file getting error ( 1007: Cannot modify...)

Post by thomas49th »

Hi I have a php file which a html file calls by require_once. I have found that if I include

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './phpbb/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
i get the error

on line 1007: Cannot modify header information - headers already sent by (output started at

but if I include this piece of code at the top of html file it works fine. What is the reason for this? Is it perhaps that the include common.php file I'm guessing it's searching for includes header functions?

Is there anyway around it

Thanks
Thomas
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Including a php file getting error ( 1007: Cannot modify

Post by requinix »

Code: Select all

include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
Any one of those lines can be trying to send a header; my guess would be the session_begin() call. That can't happen if you've already begun outputting stuff.
Post Reply