note 25101 added to function.realpath

From: Date: Tue, 10 Sep 2002 21:04:50 +0000
Subject: note 25101 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-36480@lists.php.net to get a copy of this message
Function to convert some path from PHP function into a working Window's path. This is a quick fix to my include problem and therefore may not be thuroughly tested. /** * windows_path_fix($path) * * Fix $path to work on windows machines. * * @param $path URI from PHP function, ex: getcwd(), 'c:/documents/files/' * @return string */ function windows_path_fix($path) { // is this running on a Windows machine // look at $_ENV['OS'] if ( isset($_ENV['OS']) && preg_match('/window/i', $_ENV['OS']) ) { // if Windows... // convert forward slashes '/' to back slashes '\' $path = preg_replace('/\//', '\\', $path); } return $path; } Actual usage case: // this file's document root based upon server or internal location // hard code // $doc_root = '/htdocs/www'; // automate $doc_root = ( $_SERVER['DOCUMENT_ROOT'] ) ? $_SERVER['DOCUMENT_ROOT'] : getcwd(); // this file's module directory location $mod_dir = '/'; // Cannon BOSE common methods directory $cb_dir = 'cb_common/'; // CB file's location $file_location = $doc_root . $mod_dir . $cb_dir; $file_location = windows_path_fix($file_location); -- http://www.php.net/manual/en/function.realpath.php http://master.php.net/manage/user-notes.php?action=edit+25101 http://master.php.net/manage/user-notes.php?action=delete+25101 http://master.php.net/manage/user-notes.php?action=reject+25101

« previous php.notes (#36480) next »