Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace string with include 1

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR

Hi,

I would like to replace customized tags found in a template file with an includes like this :

Code:
$code_html = str_replace("{_layout_modules_}", include("module.php"), $code_html);

But with this method, in module.php, I have to store the parsed php into a variable and then use "return".

My question is : is there a simpler way ?

Thanks ! :)


 
somewhat easier

Code:
$code_html = str_replace("{_layout_modules_}", parseFile("module.php"), $code_html);


function parseFile($filename){
 obstart();
 include $filename;
 $return = ob_get_contents();
 ob_end_clean();
 return $return;
}
 

Sorry Jpadie, but I'm having a big issue whith the ob_get_content I believe.

The problem is that personal functions that are used inside module.php throw errors :

Warning: Missing argument 4 for show_errors() ....

I'm 100% certain the function isn't to blame because it works when module.php is simply included.
Plus, the so-called missing argument is simly NULL!
I don't get it :(

Well ... if anyone heard about some well known bug ...

Thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top