Re: Include if file exists?

From: Date: Fri, 27 Aug 2004 12:38:50 +0000
Subject: Re: Include if file exists?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194923@lists.php.net to get a copy of this message
On Fri, 27 Aug 2004 12:16:32 +0200, Jay <jaynews2002@yahoo.se> wrote: > Hi! > > Is there a ready to use PHP function for including ONLY if the file exists? > > I tried it like this: > > [main.php] > include_once("lib.php"); > .....later > includeIf("somefile.php"); > > [lib.php] > function includeIf($filename) > { > if (!file_exists($filename)) > { > include_once($filename); > } > } you sure you dont mean this? function includeIf($filename) { if (file_exists($filename)) /*instead of if (!file_exists($filename))*/ { include_once($filename); } }

« previous php.general (#194923) next »