Include_once not working

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
Chrys063
Forum Newbie
Posts: 2
Joined: Tue May 10, 2005 4:28 pm

Include_once not working

Post by Chrys063 »

I'm going mad with an include_once problem here. I'm well aware that you should use include_once instead of include. I have a very large codebase that is very interconnected so I made a point of always using include_once. This afternoon, it started freaking out though. Its basically like every single include_once is acting like an include. I'm getting errors about redeclaring classes even though I always use include_once. Every single class that is included more than once, even though I'm using include_once, is causing a fatal 'Cannot redeclare class' error. Has anyone ever seen this?

I'm almost certain its a server problem. This same codebase is running on multiple servers. One of my many attempted solutions was to copy the codebase from another server that was running perfectly. This did not help at all. Are there any server settings that could cause something like this?

I'm desperate folks...

Thanks.
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

The general consensus is to use require_once instead of include_once for class's. See if changing your include_once's to require_once fixs this problem.
Chrys063
Forum Newbie
Posts: 2
Joined: Tue May 10, 2005 4:28 pm

Post by Chrys063 »

Switching to require_once had no effect. I have discovered though, that everything works perfectly once I switch all the includes to the full path to the file. I was previously using ini_set to set the include_path then just using the file name. Anyone know of any known bugs with ini_set?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Chrys063 wrote:Anyone know of any known bugs with ini_set?
Not bugs but some servers may have it disabled.
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

That would be my guess. That the server has it disabled.
Post Reply