RE: [PHP] example of file_exists() ???

From: Date: Mon, 30 Oct 2000 09:31:24 +0000
Subject: RE: [PHP] example of file_exists() ???
Groups: php.general 
Request: Send a blank email to php-general+get-22634@lists.php.net to get a copy of this message
You need the Full Path, here's a good var to trick it: $root = $DOCUMENT_ROOT; $dir = '/test'; $file = '/file.php; $my_funny_file = $root.$dir.$file; if(file_exist($my_funny_file)) { include($my_funny_file); then_go_wild(); } Basically I wrote too many staff, but what I am saying is that $DOCUMENT_ROOT is always usefull for include, require, fopen, file_exist and other functions that require full pathes. Cheers! Maxim Maletsky. -----Original Message----- From: jeremy brand [mailto:jeremy@smackdown.com] Sent: Monday, October 30, 2000 5:38 PM To: Richard Creech - DreamRiver.com; php-general@lists.php.net Subject: Re: [PHP] example of file_exists() ??? Hi Richard, Usually, you need to give a path with your function call too: for example: if (file_exists('/etc/passwd')) print 'Whoo hoo!'; If your common.php is in your current working directory, then try this: if (file_exists('./common.php')) { //do_something like an include... include('./common.php'); } Hope this helps, -jeremy brand --- "Richard Creech - DreamRiver.com" <richardc@dreamriver.com> > wrote: >Hello All, >Can someone kindly post an example of using file_exists() ??? > >I've checked the manual, read some manual notes, tried out a few variations but nada .... >This is the offensive code: > >if (file_exists("common.php")) { > require("common.php"); > $hostname = DBSERVERHOST; > //bring in the rest of the CONSTANTS, do an autologin > // more snipped code > }else{ > // do a manual login instead without common.php > } > ... and so on ... > >This is the error it gives: >Warning: Unable to access common.php >Fatal error: Failed opening required 'common.php' > >Of course it can't access common.php, it isn't there - that is what I want to test for - the absence of that common.php file! > >It would be nice if there was just ONE working example included in with the manual for each function... the manual looks clear and concise, but my code doesn't work :( > >Thank you. >Regards, > >Richard Creech >richardc@dreamriver.com Phone: 250.744.3350 Pacific Time Canada >Get a free link at http://www.dreamriver.com/phpYellow/ >Download phpYellow Pages 2000 - Now shipping Version 1.05 with EasySQL! >Add Dynamic Database Content to your Website >http://dreamriver.com/software/ > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net == _______________________________________________________________________ GnuPG Fingerprint: 9F5E 95E0 1CC2 E054 84EA 6099 8ACD 9DBA D2C0 5EA9 _ http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more __ _____________________________________________________________ Get Your Own Private, Free E-mail Now! your_name@smackdown.com http://www.smackdown.com <spacer> Half.com the hottest site for DVDs, CDs & more! Get $5 off your 1st purchase of $10 or more. http://ads.adflight.com/mach1.asp?a=19061&b=46867&c=3094 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#22634) next »