note 37715 added to function.getcwd

From: Date: Sun, 23 Nov 2003 22:50:07 +0000
Subject: note 37715 added to function.getcwd
Groups: php.notes 
Request: Send a blank email to php-notes+get-60898@lists.php.net to get a copy of this message
Make sure to lowercase the result before comparing Windows paths, because this function returns ambiguous results on Windows. From within Apache, the returned path is lowercase, while from the command line interface (CLI) the returned path uses the 'real' Windows pathname. For example, running the 'print getcwd();' command from 'C:\Program Files' returns either c:\program files (Apache) C:\Program Files (CLI) When the directory is specified using chdir(), getcwd() uses the exact chdir argument. For example: <?php chdir('C:\\PrOgRaM fIlEs'); print getcwd(); ?> outputs: C:\PrOgRaM fIlEs (Apache & CLI) The following code can be used to return a unambiguous lowercased cwd when running on Windows: <?php $sCwd = (substr(PHP_OS, 0, 3) == 'WIN') ? strtolower(getcwd()) : getcwd(); ?> ---- Manual Page -- http://www.php.net/manual/en/function.getcwd.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37715 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37715&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37715&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60898) next »