Replace string from PHP include file -
let's have include file, foo.php, , contains text "this file foo".
so, when load include using <?php include 'foo.php'; ?>
, want able replace string include before displaying text contains.
so let's want replace "foo" include "cool".
make sense?
you can use this:
<?php function callback($buffer) { return (str_replace("foo", "cool", $buffer)); } ob_start("callback"); include 'foo.php'; ob_end_flush(); ?>
Comments
Post a Comment