note 105571 modified in function.get-included-files by danbrown

From: Date: Mon, 29 Aug 2011 12:46:13 +0000
Subject: note 105571 modified in function.get-included-files by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182801@lists.php.net to get a copy of this message
This function aims to perform filtering of files that have been included : <?php function setIncludeFiles($arrayInc = array()){ $incFiles = get_included_files(); if((count($arrayInc)>0)&&(count($incFiles)>0)){ $aInt = array_intersect($arrayInc,$incFiles); if(count($aInt)>0){ return false; }elseif(count($aInt)<1) { foreach($arrayInc as $inc){ if(is_file($inc)) include($inc); else{ return false; } } } }else{ return false; } } ?> Usage : <?php $toBeInclude = array('/data/your_include_files_1.php', '/data/your_include_files_2.php', '/data/your_include_files_3.php', ); setIncludeFiles($toBeInclude); ?> Return false if something goes wrong. --was-- This function aims to perform filtering of files that have been included : function setIncludeFiles($arrayInc = array()){ $incFiles = get_included_files(); if((count($arrayInc)>0)&&(count($incFiles)>0)){ $aInt = array_intersect($arrayInc,$incFiles); if(count($aInt)>0){ return false; }elseif(count($aInt)<1) { foreach($arrayInc as $inc){ if(is_file($inc)) include($inc); else{ return false; } } } }else{ return false; } } Usage : $toBeInclude = array('/data/your_include_files_1.php', '/data/your_include_files_2.php', '/data/your_include_files_3.php', ); setIncludeFiles($toBeInclude); Return false if something goes wrong. http://php.net/manual/en/function.get-included-files.php

« previous php.notes (#182801) next »