note 19527 modified in function.require by rasmus

From: Date: Mon, 12 Aug 2002 14:25:51 +0000
Subject: note 19527 modified in function.require by rasmus
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-34872@lists.php.net to get a copy of this message
[Editor's note: This is amazingly inefficient] Alternative function of the php "require". If you need to require("file.php") multiple time like this exemple : for ($t=1; $t<=300; $t++) { require("file.php"); } You can use this function to increase speed by caching the content. function required($fileName) { global $buffer; if (!isset($buffer[$fileName])) { $fp = fopen($fileName, "r"); while (!feof($fp)) $buffer[$fileName].=fgets($fp,4096); } eval("?".">" . $buffer[$fileName] . "<"."?"); } --was-- Alternative function of the php "require". If you need to require("file.php") multiple time like this exemple : for ($t=1; $t<=300; $t++) { require("file.php"); } You can use this function to increase speed by caching the content. function required($fileName) { global $buffer; if (!isset($buffer[$fileName])) { $fp = fopen($fileName, "r"); while (!feof($fp)) $buffer[$fileName].=fgets($fp,4096); } eval("?".">" . $buffer[$fileName] . "<"."?"); } http://www.php.net/manual/en/function.require.php

« previous php.notes (#34872) next »