DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

Strange __autoload() Script Behaviour

By: rekha singh | 21 Jun 2010 11:31 am

 Hi All

 
I have 4 PHP scripts written to run in a website. Each has different functionality and they are not related in any way except that they all use objects.
 
Each script contains require('autoLoadCl asses.php' ); to load classes as required.
 
The autoloader script 'autoLoadClasses. php' that is called by each of the four scripts script is:
 
function __autoload($ class_name)
{
require('classes/ class_' . $class_name . '.php');
}
 
Then it gets strange. The first three scripts run fine - no problems, objects get created and are utilised as expected
 
But the fourth script produces the following error message:
 
Fatal error: Cannot redeclare __autoload() (previously declared in
D:\Webdesign\ Websites\ InsightCGC\ autoLoadClasses. php:2) in
D:\Webdesign\ Websites\ InsightCGC\ autoLoadClasses. php on line 5
 
So, the same 'require' instruction calling the same 'required' script but resulting in two different outcomes. Driving me crazy so any
solution(s) to this problem would be much appreciated.
 
Thanks in advance
 

Comments

No Comments Posted for this Article.

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move