note 28736 added to function.require

From: Date: Wed, 22 Jan 2003 17:19:30 +0000
Subject: note 28736 added to function.require
Groups: php.notes 
Request: Send a blank email to php-notes+get-42600@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.require.php http://master.php.net/manage/user-notes.php?action=edit+28736 http://master.php.net/manage/user-notes.php?action=delete+28736 http://master.php.net/manage/user-notes.php?action=reject+28736

« previous php.notes (#42600) next »