php load up a .php page and replace variable, and then store the output -


i load different .php page (the .php contain html , php variable need replaced.

for example:

load.php 

$output = '';

load test.php , replace $this->name value.

store html $output


load test1.php , replace $this->name value.

append previous $output variable

so @ end have $output variable have updated html

any suggestion appreciated.


test.php >

<html> <?php echo $this->name; ?> </html> 

test1.php >

<html> <?php echo $this->address; ?> </html> 

you want use output buffering require or include statement:

ob_start();  require('load.php');  $output = ob_get_contents(); ob_end_clean(); 

$output should contain contents of load.php variables processed.

to process multiple files (or else) run between ob_start() , last 2 lines, grab 2 files so:

ob_start();  require('test.php'); require('test1.php');  $output = ob_get_contents(); ob_end_clean(); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -