note 28510 rejected from function.include by avenger
| From: | avenger@php.net | Date: | Wed, 15 Jan 2003 13:11:55 +0000 |
| Subject: | note 28510 rejected from function.include by avenger | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-42176@lists.php.net to get a copy of this message | ||
Hi,
Note that include is the same is this:
<?php
$include="myfile.php";
$file=fopen($myfile,"r");
echo $output=fread($file,filesize($myfile));
fclose($file);
?>
So it is subject to every issues fopen and fread has.
Also, if you want to put a file into a variable, using
$myfile=include ("myfile.php");
Will not work, it will put the file into $myfile, but will also just do the include function and add
it anyway.
To put a file into an variable, use this:
<?php
$thefile="myfile.php";
$file=fopen($thefile,"r");
$myfile=fread($file,filesize($thefile));
fclose($file);
?>
Now you can echo the file just by using <?=$myfile?> and will not print the output before
$myfile is called like include does.
*Hopes this helps someone*