Re: Retrieve output from HTML or PHP file

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

 



Hi Peter,

Ah, I understand now.

If the file echo'ed it's output you could do:

ob_start();
include('file.php');
$output = ob_get_contents();
ob_end_clean();

or:

$output = exec('script.php');

(but make sure you use escapeshellarg &/or escapeshellcmd where applicable for security reasons).

first method would be better, more robust and more portable.

Peter Lauri wrote:
Hi Chris,

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?

Best regards,
Peter Lauri




-----Original Message-----
From: Chris [mailto:dmagick@xxxxxxxxx] Sent: Monday, January 30, 2006 11:49 AM
To: Peter Lauri
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Retrieve output from HTML or PHP file

Hi Peter,

Close :)

file('file.html');
see http://www.php.net/file
or

file_get_contents('file.html');
see http://www.php.net/file_get_contents

the 'file' function returns an array, 'file_get_contents' returns it as a string.

Peter Lauri wrote:

Best group member,



I have a php script running and need to save the output from an HTML-file

or

PHP-file. What I want to do:



$the_output = thenicefunction('file.html');



Any suggestions?



/Peter



--
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