note 36130 deleted from function.include by sniper

From: Date: Tue, 04 Nov 2003 00:43:04 +0000
Subject: note 36130 deleted from function.include by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59799@lists.php.net to get a copy of this message
Note Submitter: jeremy at image2020 dot com ---- since __FILE__ works differently for different versions of PHP you dont want to write statements like <?php include(dirname(__FILE__)."/file.php"); ?> if you are going to be distributing your script. Lets say you have the directory structure home -> sites -> site2 -> www | |-->script.php |->includes |-->includeall.php |-->file1.php |-->file2.php |-->... if you want to include all of the files in the directory includes into script.php <?php //--script.php-- include_once("/home/sites/includes/includeall.php"); ?> then in includeall.php write <?php //--includeall.php-- $inc = get_included_files(); foreach($inc as $path) { $path = pathinfo($path); if($path["basename"] == "includeall.php") { define("PATH",$path["dirname"]); break; } } include_once(PATH."/file1.php"); include_once(PATH."/file2.php"); ... ?> This way you can include all of the files in the includes directory into any script by writing one include statement, and it doesn't matter what version of PHP you are useing. PATH will contain the absolute path of the includeall.php then you can just build apon that. If you have questions about this script feel free to E-Mail me I Hope this helps somebody Good Luck

« previous php.notes (#59799) next »