note 23439 added to function.get-included-files

From: Date: Thu, 18 Jul 2002 14:54:16 +0000
Subject: note 23439 added to function.get-included-files
Groups: php.notes 
Request: Send a blank email to php-notes+get-33254@lists.php.net to get a copy of this message
I would suggest this as an alternative to the above script: function is_included($seek_file) { $included = get_included_files(); $is_included = false; reset($included); while((list($i,$file) = each($included)) && !$is_included) { $is_included = (basename($file) == $seek_file); } return $is_included; } if(!is_included('file.php')) { include_once('file.php'); } I don't think it makes sense to check for the existence of the file with file_exists() because file_exists() does not know about PHP's include_path -- so it may well say false even when include() or require() won't generate an error. -- http://www.php.net/manual/en/function.get-included-files.php http://master.php.net/manage/user-notes.php?action=edit+23439 http://master.php.net/manage/user-notes.php?action=delete+23439 http://master.php.net/manage/user-notes.php?action=reject+23439

« previous php.notes (#33254) next »