note 20523 added to ref.outcontrol

From: Date: Sat, 06 Apr 2002 13:25:57 +0000
Subject: note 20523 added to ref.outcontrol
Groups: php.notes 
Request: Send a blank email to php-notes+get-28698@lists.php.net to get a copy of this message
You can use the ob_*-functions to replace the PHP variables in a file with its actual content. It is useful when you have a template file which includes some variables, like "User=$user" a.s.o. (Probably there is an easier way?): $sf = fopen($sourcefile, "r"); $df = fopen($destfile, "w"); ob_start(); while( !feof($sf) ) { $line = fgets($sf, 4096); $eval = "echo \"".addslashes($line)."\";"; eval($eval); $line = ob_get_contents(); fputs($df, stripslashes($line)); } ob_end_clean(); Possibly, it helps someone... -- http://www.php.net/manual/en/ref.outcontrol.php http://master.php.net/manage/user-notes.php?action=edit+20523 http://master.php.net/manage/user-notes.php?action=delete+20523 http://master.php.net/manage/user-notes.php?action=reject+20523

« previous php.notes (#28698) next »