note 28102 deleted from function.include by sniper

From: Date: Sat, 18 Jan 2003 15:22:37 +0000
Subject: note 28102 deleted from function.include by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-42346@lists.php.net to get a copy of this message
If you like to use a nested file structure and include lots of files, then the easiest way is to use a common include file (includeAll.php) to include all the other files you require. This way you only need to specify one relative path and the below code works out the relative paths for the other files. # page3.php ~~~~~~~ include("common/includeAll.php"); ~~~~~~~ or # subDir/page9.php ~~~~~~~ include("../common/includeAll.php"); ~~~~~~~ # includeAll.php ~~~~~~~ // adjust this figure to reflect the depth of your common or library files $libDir = 3; // split the path of the file calling the includeAll page list($d1, $d2, $d3, $d4, $d5, $d6, $d7, $d8, $d9) = split("/", $_SERVER["PHP_SELF"]); for ($i=$libDir; $i<=9; $i++) { $thisDir = "d" . $i; // if url chunk is actual php page then terminate loop if(ereg(".php",$$thisDir)) { $i = 99; } // else add extra relative directory path else { $relDir .= "../"; } } ~~~~~~~ include($relDir . 'common/lib/sessions.php'); include($relDir . 'common/class/mysql.php'); //etc

« previous php.notes (#42346) next »