Jump to content

Include multiple files with the same function name in it using ob_start ...


Recommended Posts

Hi,

 

I want to include in the same php file, more php files (one by one), to cache the result, and the result to write in an other file, what I do:

 

// For more files that I have, I do this		
$filename = <some file>

ob_start();
include $filename;

$contents = ob_get_contents();
ob_end_clean();

// Write contents to another static (html) file

 

The problem is that I include more files, but they can have a function that repeats, so I get an error duplicate function.

 

Why ob_end_clean() does not clean the buffer, as it would never exist.

 

Any ideas?

 

Thanks in advance

The output buffering functions only act on output from your script; they have nothing to do with warnings or errors raised (by repeating function names, or anything else).

 

The solution is just to not have repeating function names.

The thing is that I can not really control this thing about the functions (this is natural that this can happen) as the user will add this content.

I want to overpass this somehow, to include the files independently some how.

The thing is that I can not really control this thing about the functions (this is natural that this can happen) as the user will add this content.

I want to overpass this somehow, to include the files independently some how.

 

You can't. Don't create functions of the same name within the same namespace.

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.