PHP Autoload Not Working

Status
Not open for further replies.

MrDare360

New Member
Messages
3
Reaction score
0
Points
0
I have a script which requires the PHP function __autoload() to be enabled, currently it is not and I was wondering if there would be any way to enable it for my website at http://www.ablp.x10.mx/Blog

The script can not work unless it is activated. Is there any way to fix this?
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Well, __autoload() is just syntactic sugar, so any script that uses it can easily be re-written to avoid it (using require_once and explicit filenames prior to using the classes). I can't speak to the matter of enabling it (or what it might not be enabled), other than to say that it would be server-wide and not per-account.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Looking at the error message ... are you sure you didn't misspell something?

Class 'Autho'

Maybe the Class is named Author ?
 

MrDare360

New Member
Messages
3
Reaction score
0
Points
0
Well, __autoload() is just syntactic sugar, so any script that uses it can easily be re-written to avoid it (using require_once and explicit filenames prior to using the classes). I can't speak to the matter of enabling it (or what it might not be enabled), other than to say that it would be server-wide and not per-account.

Alright, do you know a solution to loading all the files in Application/Core that ends with .class.php and loading every file from Application/Controllers and Application/Models?

This is what I was using before but I do not know how I could automate the process without using __autoload()

PHP:
function __autoload($filename) {
    if(file_exists(CORE . strtolower($filename) . '.class.php')) 
        require_once(CORE . strtolower($filename) . '.class.php');	 
    else if(file_exists(CORE . strtolower($filename) . '.php')) 		
        require_once(CORE . strtolower($filename) . '.php');	 
    else if(file_exists(MODELS . strtolower($filename) . '.php')) 		
        require_once(MODELS . strtolower($filename) . '.php');	 
    else if(file_exists(CONTROLLERS . strtolower($filename) . '.php')) 		
        require_once(CONTROLLERS . strtolower($filename) . '.php');}

Looking at the error message ... are you sure you didn't misspell something?



Maybe the Class is named Author ?

It is spelled correctly, I like to abbreviate names to save keystrokes, Autho stands for Authorization to me ;)
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
The automation is not "required", it's just nice to have. That's what syntactic sugar means. You can use require_once and explicit filenames, as I said.
 

MrDare360

New Member
Messages
3
Reaction score
0
Points
0
The automation is not "required", it's just nice to have. That's what syntactic sugar means. You can use require_once and explicit filenames, as I said.

Alright, all fixed now. Thanks for the help.
 
Status
Not open for further replies.
Top