note 82329 rejected from function.file-exists by nlopess

From: Date: Sat, 12 Apr 2008 10:28:54 +0000
Subject: note 82329 rejected from function.file-exists by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-138221@lists.php.net to get a copy of this message
Note Submitter: tom at tombamford dot co dot uk ---- I've encountered the same problem as stuart. file_exists() returns false falses if you use a constant as part of the filename when calling it. Putting the same filename into a variable beforehand and specifying that instead works. <? define("CLASS_DIR", "/home/web/classes"); $class_name = "Page"; $dirs = array("", "data/", "output/", "ebay/"); // Does not work foreach($dirs as $dir){ if(file_exists(CLASS_DIR.$dir.$class_name.".class.php")) require_once(CLASS_DIR.$dir.$class_name.".class.php"); } // Works foreach($dirs as $dir){ $filename = CLASS_DIR.$dir.$class_name.".class.php"; if(file_exists($filename)) require_once($filename); } ?>

« previous php.notes (#138221) next »