note 116958 added to function.symlink
| From: | flobee | Date: | Thu, 26 Mar 2015 15:55:34 +0000 |
| Subject: | note 116958 added to function.symlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202048@lists.php.net to get a copy of this message | ||
sym/hard linking i love to do it relative a lot but not that trivial when thinking wrong :-)
manpage says: the target is the _linkname_ and from that point to create relative links successful
is to start from the directory where the link should be created e.g.:
/myfiles/now/here/
/myfiles/links/
chdir( realpath(dirname($target)));
You need to create/find out the relativ path to the source, otherwise the absolut path will be used
in a link.
if you start to create the target path from the source eg:
"/myfiles/now/here/../../later/" and links should go to /myfiles/later/ you need to use
realpath( dirname() ) set the new location using chdir() and start from here to link to the source
which is ../now/here/
This you can find out e.g.: when having the absolut path of source and target:
$dirTo = realpath(dirname($to));
chdir($dirTo);
$linkName = basename($to);
$target = $dirTo . DIRECTORY_SEPARATOR . $linkName;
$srcFile = getRelativeDirectory($from, $to); //basicly a function which will find the from -> to,
but in this case the from ist the target where you need to start.
below you can find some examples how to split the path in chunks to find a relativ path
----
Server IP: 72.52.91.14
Probable Submitter: 80.171.17.119
----
Manual Page -- http://php.net/manual/en/function.symlink.php
Edit -- https://master.php.net/note/edit/116958
Del: integrated -- https://master.php.net/note/delete/116958/integrated
Del: useless -- https://master.php.net/note/delete/116958/useless
Del: bad code -- https://master.php.net/note/delete/116958/bad+code
Del: spam -- https://master.php.net/note/delete/116958/spam
Del: non-english -- https://master.php.net/note/delete/116958/non-english
Del: in docs -- https://master.php.net/note/delete/116958/in+docs
Del: other reasons-- https://master.php.net/note/delete/116958
Reject -- https://master.php.net/note/reject/116958
Search -- https://master.php.net/manage/user-notes.php