RE: [PHP] fread problem
| From: | John W. Holmes | Date: | Mon, 03 Mar 2003 04:57:08 +0000 |
| Subject: | RE: [PHP] fread problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137850@lists.php.net to get a copy of this message | ||
> I am trying to read a php file to a varible and then print that
variable.
> Unfortunately, my php file is not being parsed by the fread function
and I
> can't figure out why.
>
> Here is the code in my file and was taken directly from the manual:
>
> $filename = "test.php";
> $handle = fopen ($filename, "r");
> $contents = fread ($handle, filesize ($filename));
> fclose ($handle);
> echo $contents;
>
> Here is test.php >>>
>
> <?PHP
> echo "Hello World";
> ?>
>
> <<< END test.php
>
>
> When I run this, I get a blank page with my php code as my HTML source
> code.
> Not good.
If you want the result of your PHP file, then open it through HTTP.
$filename = "http://www.yourdomain.com/test.php";
and everything else remains the same.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/