alexweber15 Posted September 19, 2009 Share Posted September 19, 2009 I'm trying to figure out what's the point of this function!! I registered the extensions I'm using ('.class.php,.php') and correctly set up my include path but the I get warnings saying that "path/to/file" can't be found. (even though the class is located in path/to/file.class.php) I also use some 3rd party components that are named "file.php" so I've got to account for both. Now, I've figured it out and my autoloader works fine, but I'm really just wondering what's the point of spl_autoload_extensions if I have to manually specify the extensions myself?? The more intuitive approach would be that you could leave out the extensions and it would automatically search for both types right? Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/ Share on other sites More sharing options...
corbin Posted September 19, 2009 Share Posted September 19, 2009 It defaults to <class name in lowercase>.inc or <class name in lowercase>.php. Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921283 Share on other sites More sharing options...
alexweber15 Posted September 20, 2009 Author Share Posted September 20, 2009 It defaults to <class name in lowercase>.inc or <class name in lowercase>.php. I realize that! I've changed it to use: <class name in lowercase>.class.php and <class name in lowercase>.php But in my include statement in my autoloader i still end up having to manually specify the extension if not it doesnt find my classes.... Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921739 Share on other sites More sharing options...
Daniel0 Posted September 20, 2009 Share Posted September 20, 2009 This function can modify and check the file extensions that the built in __autoload() fallback function spl_autoload() will be using. If you make your own autoloading function, there will not be used any fallback. Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921741 Share on other sites More sharing options...
alexweber15 Posted September 20, 2009 Author Share Posted September 20, 2009 This function can modify and check the file extensions that the built in __autoload() fallback function spl_autoload() will be using. If you make your own autoloading function, there will not be used any fallback. So basically if I have no autoloader expilcitly defined but I define spl_autoload_extensions() then the fallback will look in my include_path for corresponding files with the defined extensions? Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921794 Share on other sites More sharing options...
Daniel0 Posted September 20, 2009 Share Posted September 20, 2009 This function is intended to be used as a default implementation for __autoload(). If nothing else is specified and autoload_register() is called without any parameters then this functions will be used for any later call to __autoload(). Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921796 Share on other sites More sharing options...
alexweber15 Posted September 20, 2009 Author Share Posted September 20, 2009 thanks ill give it a shot Quote Link to comment https://forums.phpfreaks.com/topic/174805-solved-proper-usage-of-spl_autoload_extensions/#findComment-921879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.