note 103482 added to function.require-once

From: Date: Fri, 15 Apr 2011 13:51:40 +0000
Subject: note 103482 added to function.require-once
Groups: php.notes 
Request: Send a blank email to php-notes+get-178874@lists.php.net to get a copy of this message
perfected the import fuction: - removed the session bug, now the restrictions are per-file. - now it's recursive, it will get into subpackages too. - files are still required to be ".class.php"; <?php function import($path=""){ if($path == ""){ //no parameter returns the file import info tree; $report = $_SESSION['imports']; foreach($report as &$item) $item = array_flip($item); return $report; } $current = str_replace("\\","/",getcwd())."/"; $path = $current.str_replace(".","/",$path); if(substr($path,-1) != "*") $path .= ".class.php"; $imports = &$_SESSION['imports']; if(!is_array($imports)) $imports = array(); $control = &$imports[$_SERVER['SCRIPT_FILENAME']]; if(!is_array($control)) $control = array(); foreach(glob($path) as $file){ $file = str_replace($current,"",$file); if(is_dir($file)) import($file.".*"); if(substr($file,-10) != ".class.php") continue; if($control[$file]) continue; $control[$file] = count($control); require_once($file); } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 187.55.215.170 ---- Manual Page -- http://www.php.net/manual/en/function.require-once.php Edit -- https://master.php.net/note/edit/103482 Del: integrated -- https://master.php.net/note/delete/103482/integrated Del: useless -- https://master.php.net/note/delete/103482/useless Del: bad code -- https://master.php.net/note/delete/103482/bad+code Del: spam -- https://master.php.net/note/delete/103482/spam Del: non-english -- https://master.php.net/note/delete/103482/non-english Del: in docs -- https://master.php.net/note/delete/103482/in+docs Del: other reasons-- https://master.php.net/note/delete/103482 Reject -- https://master.php.net/note/reject/103482 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178874) next »