note 52787 deleted from function.realpath by tularis

From: Date: Thu, 12 May 2005 14:45:44 +0000
Subject: note 52787 deleted from function.realpath by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89334@lists.php.net to get a copy of this message
Note Submitter: Santa Reason: useless ---- The htmlpath function suggested beforehand can be useful, but causes problems on (my) webserver under windows. My apache gives me backslashes in the $_SERVER['DOCUMENT_ROOT'] variable, but normal slashes in any path given back by the realpath() function. So the str_replace function doesn't work. Possible solution: Ensure the use of the same slashes by using realpath($_SERVER['DOCUMENT_ROOT']) instead of $_SERVER['DOCUMENT_ROOT'] only. So the example looks like: <?php function htmlpath($relative_path) { $realpath = realpath($relative_path); $htmlpath = str_replace(realpath($_SERVER['DOCUMENT_ROOT']),'',$realpath); return $htmlpath; } echo '<img src="', htmlpath('../../relative/path/to/file.ext'), '" border=1>'; ?>

« previous php.notes (#89334) next »