note 111338 added to function.realpath
| From: | Anonymous | Date: | Sat, 09 Feb 2013 00:01:36 +0000 |
| Subject: | note 111338 added to function.realpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193561@lists.php.net to get a copy of this message | ||
small modification for get_absolute_path posted by previous user, it fails with linux, missing the
first /
function get_absolute_path($path) {
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) continue;
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
return
(strtolower(php_uname("s"))=="linux"?"/":"").implode(DIRECTORY_SEPARATOR,
$absolutes);
}
----
Server IP: 69.147.83.199
Probable Submitter: 79.153.0.80
----
Manual Page -- http://php.net/manual/en/function.realpath.php
Edit -- https://master.php.net/note/edit/111338
Del: integrated -- https://master.php.net/note/delete/111338/integrated
Del: useless -- https://master.php.net/note/delete/111338/useless
Del: bad code -- https://master.php.net/note/delete/111338/bad+code
Del: spam -- https://master.php.net/note/delete/111338/spam
Del: non-english -- https://master.php.net/note/delete/111338/non-english
Del: in docs -- https://master.php.net/note/delete/111338/in+docs
Del: other reasons-- https://master.php.net/note/delete/111338
Reject -- https://master.php.net/note/reject/111338
Search -- https://master.php.net/manage/user-notes.php