PC Nerd Posted April 18, 2010 Share Posted April 18, 2010 Hi, I've written this small __autoload for my page, and it's echoing the correct file out, however I get the "Class blah not defined" in my script. I've root (/) in the filenames is the root of the installation, and htdocs i the only web accessable folder. From the echo below, I get: "../system/classes/UI.class.php", which definately exists. I'm stumped. Thanks for any help. PC_Nerd /htdocs/index.php <?php function __autoload ($className) { $filename =$className.'.class.php'; $filename = str_replace('\\', "/", $filename); if ( preg_match( '/[\w\d\.]+\.php$/', $filename, $matches) ) { $filename=SYSTEM_DIR."classes/".$matches[0]; if(file_exists($filename)) { require_once $filename; return; } else { echo "The file: ".$filename." -> was not found.\n"; } } throw new Exception("Required file was not found: ".$filename." - Class not loaded"); } ?> /system/classes/UI.class.php <?php namespace framework\ui; class UI extends framework\system\Singleton { } ?> Link to comment https://forums.phpfreaks.com/topic/198923-__autoload-displays-correct-file-but-does-not-include-it-properly/ Share on other sites More sharing options...
PC Nerd Posted April 18, 2010 Author Share Posted April 18, 2010 Solved (myself) Somehow its started working. I looked into how the names were getting passed and I think its to do with this being the second __autorun call, based on another dependency... I had named namespaces without the leading \ and thus I was attempting to access \framework\system\framwork\ui\UI etc.... just like a filysystem only crunchy! Thanks Link to comment https://forums.phpfreaks.com/topic/198923-__autoload-displays-correct-file-but-does-not-include-it-properly/#findComment-1044170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.