note 28736 deleted from function.require by sniper

From: Date: Tue, 04 Nov 2003 00:44:21 +0000
Subject: note 28736 deleted from function.require by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59812@lists.php.net to get a copy of this message
Note Submitter: jordy@querner.com ---- I wanted a script to include all the files in my include dir. And require all the class files. I have a dir called: /home/apache/www.querner.com/inc that contains all the php function libs with a .inc extention and all the classes have a .class extention. I include config.inc in every page on the site. <begin config.inc> $thispath = "/home/apache/www.querner.com/inc/"; // name of this file to prevent a infinit loop $self = "config.inc"; $fstream = opendir($thispath); while ($fentry = readdir($fstream)) { if (is_file("$thispath/$fentry") and $fentry != "$self") { if (preg_match("/\.inc/i",$fentry)) include("$thispath/$fentry"); elseif (preg_match("/\.class/i",$fentry)) require("$thispath/$fentry"); } } closedir($fstream); <end config.inc> note: use .htaccess so that .inc and .class files cannot be approached directy from the webserver.

« previous php.notes (#59812) next »