note 49805 added to function.file-exists

From: Date: Wed, 09 Feb 2005 05:08:17 +0000
Subject: note 49805 added to function.file-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-84701@lists.php.net to get a copy of this message
I spent the last two hours wondering what was wrong with my if statement: file_exists($file) was returning false, however I could call include($file) with no problem. It turns out that I didn't realize that the php include_path value I had set in the .htaccess file didn't carry over to file_exists, is_file, etc. Thus: <?PHP // .htaccess php_value include_path '/home/user/public_html/'; // includes lies in /home/user/public_html/includes/ //doesn't work, file_exists returns false if ( file_exists('includes/config.php') ) { include('includes/config.php'); } //does work, file_exists returns true if ( file_exists('/home/user/public_html/includes/config.php') ) { include('includes/config.php'); } ?> Just goes to show that "shortcuts for simplicity" like setting the include_path in .htaccess can just cause more grief in the long run. ---- Manual Page -- http://www.php.net/manual/en/function.file-exists.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49805 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49805&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49805&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49805&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49805&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49805&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49805&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84701) next »