note 88421 added to function.realpath

From: Date: Fri, 23 Jan 2009 12:40:13 +0000
Subject: note 88421 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-149686@lists.php.net to get a copy of this message
There's a little bug in Isaac Z. Schlueter's function. If your path contains "0" (or any "false" string) directory name, the function removes that directory from the path. A little fix follows. <?php function resolve_href ($base, $href) { /* code omitted */ // resolve /../ // loop through all the parts, popping whenever there's a .., pushing otherwise. $parts = array(); foreach ( explode('/', preg_replace('~/+~', '/', $path)) as $part ) if ($part === "..") { array_pop($parts); } elseif ($part!="") { $parts[] = $part; } /* code omitted */ } ?> ---- Server IP: 78.41.104.32 Probable Submitter: 80.250.189.67 ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- https://master.php.net/note/edit/88421 Del: integrated -- https://master.php.net/note/delete/88421/integrated Del: useless -- https://master.php.net/note/delete/88421/useless Del: bad code -- https://master.php.net/note/delete/88421/bad+code Del: spam -- https://master.php.net/note/delete/88421/spam Del: non-english -- https://master.php.net/note/delete/88421/non-english Del: in docs -- https://master.php.net/note/delete/88421/in+docs Del: other reasons-- https://master.php.net/note/delete/88421 Reject -- https://master.php.net/note/reject/88421 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149686) next »