note 23439 deleted from function.get-included-files by sniper

From: Date: Thu, 25 Sep 2003 17:25:14 +0000
Subject: note 23439 deleted from function.get-included-files by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57125@lists.php.net to get a copy of this message
Note Submitter: hans@velum.net ---- 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.

« previous php.notes (#57125) next »