Jump to content

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


dymon

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.

Archived

This topic is now archived and is closed to further replies.

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