Home > Archive > PHP Language > August 2006 > Need to Include file multiple times
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need to Include file multiple times
|
|
| djoshea@gmail.com 2006-08-24, 6:57 pm |
| I need to include certain .php files multiple times. These php files
contain functions and possibly classes, and also have embedded html
content and echo statements that were previously rendered onto the
current page using an include() statement.
Now, I want to be able to render the content of these files onto the
page multiple times, but I'm not sure how to do this without running
into function and class redefinition problems. The pages are designed
to be included once into the content area of the page. I'd like to
include the same file multiple times into the content area without
modifying these files (if possible).
Any suggestions?
| |
|
| djoshea@gmail.com wrote:
> I need to include certain .php files multiple times. These php files
> contain functions and possibly classes, and also have embedded html
> content and echo statements that were previously rendered onto the
> current page using an include() statement.
>
> Now, I want to be able to render the content of these files onto the
> page multiple times, but I'm not sure how to do this without running
> into function and class redefinition problems. The pages are designed
> to be included once into the content area of the page. I'd like to
> include the same file multiple times into the content area without
> modifying these files (if possible).
I'd say it is a Bad Idea.
Why not split you content and functions? require_once would then be your
answer.
It cannot be done without altering the files, allthough you could
encorporate every function / class definition in respectively
if(!function_exists('function_name')) or a if(!class_exists('class_name'))
--
Grtz,
Rik Wasmus
| |
| Mumia W. 2006-08-24, 6:57 pm |
| On 08/24/2006 01:51 PM, djoshea@gmail.com wrote:
> I need to include certain .php files multiple times. These php files
> contain functions and possibly classes, and also have embedded html
> content and echo statements that were previously rendered onto the
> current page using an include() statement.
>
> Now, I want to be able to render the content of these files onto the
> page multiple times, but I'm not sure how to do this without running
> into function and class redefinition problems. The pages are designed
> to be included once into the content area of the page. I'd like to
> include the same file multiple times into the content area without
> modifying these files (if possible).
>
> Any suggestions?
>
Change those .php files to only define functions--functions
that output HTML when called. Use require_once to load the
..php files and their functions and call those functions when
you need their HTML outputs.
|
|
|
|
|