Page 1 of 1

Include_once not working

Posted: Tue May 10, 2005 4:35 pm
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.

Posted: Wed May 11, 2005 7:58 am
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.

Posted: Wed May 11, 2005 10:42 am
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?

Posted: Wed May 11, 2005 11:54 am
by Chris Corbyn
Chrys063 wrote:Anyone know of any known bugs with ini_set?
Not bugs but some servers may have it disabled.

Posted: Wed May 11, 2005 7:02 pm
by php_wiz_kid
That would be my guess. That the server has it disabled.