note 60411 added to function.realpath

From: Date: Fri, 06 Jan 2006 01:35:13 +0000
Subject: note 60411 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-101284@lists.php.net to get a copy of this message
I found realpath stopped working when I moved to a shared hosting server. I was using it to determine relative paths between files, basically changing paths like: user/stuff/things/../items/file.htm to user/stuff/items/file.htm Since I don't specifically need realpath for this (in my app), I used the following regex bodge to delete the ../ and the preceeding folder from the string: { $path = eregi_replace("[^/]*/..?/","",$path); } Hope someone finds this useful! Note: Before anyone asks why you'd have that dumb path in the first place, it's part of a larger script that re-links HREFS in documents to be relative to the script's location not the page. There's probably a much nicer way to achieve this, but what the hell. ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60411 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60411&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60411&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101284) next »