note 51687 added to function.include
| From: | me at kromefx dot com | Date: | Thu, 07 Apr 2005 15:28:58 +0000 |
| Subject: | note 51687 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87662@lists.php.net to get a copy of this message | ||
it seems that fread'ing a file, buffering the content, and eval'ing the content is faster
than standard include in all the tests that i've run. Can anyone else verify this or know why i
shouldn't code this way?
<?
$filename='included_file.php';
$handle = fopen ($filename, 'r');
$content = fread ($handle, filesize ($filename));
fclose ($handle);
ob_start();
eval('?>' . $content . '<?');
$content=ob_get_contents();
ob_end_clean();
echo $content;
?>
seems to run faster than:
<?
include('included_file.php');
?>
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51687
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51687&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51687&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51687&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51687&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51687&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51687&report=yes
Search -- http://master.php.net/manage/user-notes.php