#43380 [Fbk->Bgs]: incorrect file_exists() results in destructors

From: Date: Sat, 24 Nov 2007 12:26:41 +0000
Subject: #43380 [Fbk->Bgs]: incorrect file_exists() results in destructors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120011@lists.php.net to get a copy of this message
ID: 43380 Updated by: jani@php.net Reported By: orlandu96 at gmail dot com -Status: Feedback +Status: Bogus Bug Type: Filesystem function related Operating System: Windows XP SP2 PHP Version: 5.2.5 New Comment: See bug #42626 Previous Comments: ------------------------------------------------------------------------ [2007-11-24 12:24:50] jani@php.net Try checking the current working directory using getcwd(). I bet it's not what you expect. ------------------------------------------------------------------------ [2007-11-22 17:58:02] orlandu96 at gmail dot com Description: ------------ file_exists() always returns false for relative URIs when called in a class destructor. Reproduce code: --------------- class test { public $file = 'index.php'; function checkFile() { if(file_exists($this->file)) { echo "{$this->file} exists"; } else { echo "{$this->file} doesn't exist"; } echo "\n"; } function __destruct() { echo 'test::__destruct() : '; $this->checkFile(); echo 'test::__destruct() : '; if(file_exists(__FILE__)) { echo __FILE__, ' exists'; } else { echo __FILE__, ' doesn\'t exist'; } } } $test = new test; echo 'test::checkFile() : '; $test->checkFile(); Expected result: ---------------- test::checkFile() : index.php exists test::__destruct() : index.php exists test::__destruct() : C:\xampp\htdocs\templating\index.php exists Actual result: -------------- test::checkFile() : index.php exists test::__destruct() : index.php doesn't exist test::__destruct() : C:\xampp\htdocs\templating\index.php exists ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43380&edit=1

« previous php.bugs (#120011) next »