Jump to content

set require_once? So the file is not loaded later on in the script.


Recommended Posts

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



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.

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...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.