carsten888 Posted September 16, 2011 Share Posted September 16, 2011 Is it possible to set the require_once, so that later in the script PHP does not require_once the file? $file = $root.'filename.php'; set_require_once($file);//this would be nice require_once($file);//so this does not load Quote Link to comment https://forums.phpfreaks.com/topic/247252-set-require_once-so-the-file-is-not-loaded-later-on-in-the-script/ Share on other sites More sharing options...
Pikachu2000 Posted September 16, 2011 Share Posted September 16, 2011 That's the whole point of using require_once, so the file is only loaded once during the execution of a script. If that isn't what you mean, please explain. Quote Link to comment https://forums.phpfreaks.com/topic/247252-set-require_once-so-the-file-is-not-loaded-later-on-in-the-script/#findComment-1269930 Share on other sites More sharing options...
WebStyles Posted September 16, 2011 Share Posted September 16, 2011 yes, require_once already does that for you. require_once($file);//this will load require_once($file);//this will not load unless you're talking about different file names, and you only want to load say file2 if file1 hasn't been loaded yet... Quote Link to comment https://forums.phpfreaks.com/topic/247252-set-require_once-so-the-file-is-not-loaded-later-on-in-the-script/#findComment-1269942 Share on other sites More sharing options...
carsten888 Posted September 16, 2011 Author Share Posted September 16, 2011 sorry guys, I guess I did not explain enough of what I mean. This is for the Joomla framework. To override core functionality you can load a copy of a core-class (in another file then the core file). The Joomla core will then not load that same class again. So far so good. Problems come when other Joomla plugins try to directly require_once the core-file with the original class which has already been loaded. Obviously, that produces an error. So what I need is a way to tell PHP that that file has already been loaded, to prevent other plugins trying to require_once the file with the class which is already loaded. I hope that makes more sense now. Quote Link to comment https://forums.phpfreaks.com/topic/247252-set-require_once-so-the-file-is-not-loaded-later-on-in-the-script/#findComment-1269953 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.