note 54951 added to function.realpath

From: Date: Wed, 20 Jul 2005 15:55:45 +0000
Subject: note 54951 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-92217@lists.php.net to get a copy of this message
You have a realpath. Now you want a htmlpath. First Suggestion: <?php function htmlpath($relative_path) { $realpath=realpath($relative_path); $htmlpath=str_replace($_SERVER['DOCUMENT_ROOT'],'',$realpath); return $htmlpath; } ?> But this does not work on some servers. Second Suggestion: <?php function htmlpath($realpath) { $i = substr_count($_ENV["SCRIPT_URL"],'/')."<br>"; $baserealpath=realpath(str_repeat('../',$i-1)); $htmlpath=str_replace($baserealpath,'',$realpath); return $htmlpath; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54951 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54951&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54951&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92217) next »