RE: [PHP] Retrieve output from HTML or PHP file

From: Date: Mon, 30 Jan 2006 05:27:51 +0000
Subject: RE: [PHP] Retrieve output from HTML or PHP file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-229443@lists.php.net to get a copy of this message
Peter Lauri wrote: > As I read in the documentation it only takes the content of the file. If > there is a script in the file I want that to be fun first. A file like > this: > > ---------- > HTLM content > <?php echo 'Hello World'; ?> > HTML content > ---------- > > I want the result from my function to be > > ---------- > HTLM content > Hello World > HTML content > ---------- > > The file_get_contents('file.html') will give me > > ---------- > HTLM content > <?php echo 'Hello World'; ?> > HTML content > ---------- > > Or am I not correct? Yes you are correct. Why don't you include the file? PHP will parse the PHP inside it and output the HTML... If you want to get the contents into a variable then do something like: <? ob_start(); include("file.html"); $fileContent = ob_get_contents(); ob_clean(); ?> Albert -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27

« previous php.general (#229443) next »