Reply to Re: How to echo content of a file?

Your name:

Reply:


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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация