note 28510 added to function.include

From: Date: Wed, 15 Jan 2003 12:19:44 +0000
Subject: note 28510 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-42173@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* -- http://www.php.net/manual/en/function.include.php http://master.php.net/manage/user-notes.php?action=edit+28510 http://master.php.net/manage/user-notes.php?action=delete+28510 http://master.php.net/manage/user-notes.php?action=reject+28510

« previous php.notes (#42173) next »