• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Another include() problem

harrylmh

New Member
Hi,

I have a .inc file that contains html codes. How do I use the include() to print the codes out onto the page so that others can select it and copy it?

I know there's htmlspecialchars(), but how do I pass the contents of the entrire file into this function?

I tried this and it does work:
PHP:
$contents = include ("html_test.inc");
							  $contents = htmlspecialchars($contents, ENT_QUOTES);
							  echo $contents;

PS: It contains many double-quotes.

Hope you can help.
regards
 
Last edited:
PHP:
<?
$file = fopen("html_test.inc", "r");
while(!feof($file))
{
    $a = fgets($file, 1024);
    $b = htmlspecialchars($a);
    echo $b."<br>";
}
?>
I think this should work
 
then it should look like this
PHP:
<?
$file = readfile("html_test.inc");
$text = htmlspecialchars($file);
echo $text;
?>
but it's the same as i posted before
 
The first method causes both my IE and Opera to hang (strange). The readfile method inserts the contents instead of printing the code without getting the browser to render it.

What else can I try?
 
Back
Top