c96jg
asked on
Unique includes
HI,
I think if there is a positive answer to this, then it'll be a complicated answer.
What I want to do is call some PHP script that is determined by values in the db, this will be performed in a loop n number of time. n will be determined by the number of records in the db.
The problems is, if the same peace of script is include more than once, there is potential clash of defined functions within the scripts.
I don't want to have to make sure all the scripts (in time potently 100's, if not 1000's) have unique function names.
Because of this, include and require are of no use to me, does anyone have a alternative idea, of how I could achieve this?
What I really want to be able to do is run or de_include an include file.
Thanks,
I think if there is a positive answer to this, then it'll be a complicated answer.
What I want to do is call some PHP script that is determined by values in the db, this will be performed in a loop n number of time. n will be determined by the number of records in the db.
The problems is, if the same peace of script is include more than once, there is potential clash of defined functions within the scripts.
I don't want to have to make sure all the scripts (in time potently 100's, if not 1000's) have unique function names.
Because of this, include and require are of no use to me, does anyone have a alternative idea, of how I could achieve this?
What I really want to be able to do is run or de_include an include file.
Thanks,
can do with
if(!function_exists(any_fu nction_nam e)){
include("yourfile.php");
}
Lk
if(!function_exists(any_fu
include("yourfile.php");
}
Lk
In my opinion, the method dkjariwala mentioned is the most efficient way. I always use include_once() for my scripts, as it just keeps you from making stupid mistakes by accidentally including the same file (functions) twice.
There is also the ability to see what files are included by using the get_included_files() function, but include_once() is the best method.
http://www.php.net/manual/en/function.include-once.php
http://www.php.net/manual/en/function.get-included-files.php
Regards,
Barry
There is also the ability to see what files are included by using the get_included_files() function, but include_once() is the best method.
http://www.php.net/manual/en/function.include-once.php
http://www.php.net/manual/en/function.get-included-files.php
Regards,
Barry
ASKER
HI,
Thanks for the responses but include_once or require_once doesn’t solve the problem, as it is possible there will be code that gets executed on the inclusion. I.e. code not in a function. This code will need to be executed every time the inclusion happens. I can get a work around but would like to avoid it if I can.
Plus as implied in the question, there may in time be 2 or more functions with the same name in differant include doing differant things. Which is why I'm looking for a run type thing as oposed to an include.
Any other ideas?
Jim
Thanks for the responses but include_once or require_once doesn’t solve the problem, as it is possible there will be code that gets executed on the inclusion. I.e. code not in a function. This code will need to be executed every time the inclusion happens. I can get a work around but would like to avoid it if I can.
Plus as implied in the question, there may in time be 2 or more functions with the same name in differant include doing differant things. Which is why I'm looking for a run type thing as oposed to an include.
Any other ideas?
Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JD