|
Posted by Kimmo Laine on 11/27/93 11:25
<talthen.z-serwera.o2@nospam.pl> kirjoitti
viestissδ:df52e5$m6q$1@atlantis.news.tpi.pl...
> Hello,
> I have a file that looks like this:
> =========
> <td valign='top'>Data</td>
> <td><input type='text' name='Data' value="$_REQUEST['Data']" size='50'>
> </td>
> =========
> I would like to include this in my script, but I want the $_REQUEST to be
> automatically filled.
> When I do:
> include 'file';
> I have this printed to output AS-IS.
>
> I would like to treat file as string for echo (smth like:)
> $x=include 'file';
> echo $x;
> However it doesn't work.
$x = file_get_contents('file');
echo $x;
// note: file_get_contents requires quite new version of php, it was added
quite recently. although I can't remeber in which version it was added.
or
$x = implode('', file('file'));
echo $x;
or
ob_start();
readfile('file');
$x = ob_get_clean();
echo $x;
I can think of some more, but those would be the easiest. In the examples
above, if the file contains php, it will not be parsed and executed. Now if
you happen to have a file with php content and want it to be executed, then
you do this:
ob_start();
include('file');
$x = ob_get_clean();
echo $x;
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <eternal.erectionN0@5P4Mgmail.com>
[Back to original message]
|