RE: Retrieve output from HTML or PHP file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux