note 74411 added to function.symlink
| From: | egingell at sisna dot com | Date: | Tue, 10 Apr 2007 15:03:32 +0000 |
| Subject: | note 74411 added to function.symlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125264@lists.php.net to get a copy of this message | ||
Windows Vista has its own symlink program now (mklink). Hopefully future versions of PHP for Windows
will have this function put it?
Anyway, this will work on Vista (assuming your PHP user has the proper permissions):
<?php
define('SYMLINK_FILE' = 0);
define('SYMLINK_DIR' = 1);
define('SYMLINK_JUNCTION' = 2);
function symlink ($target, $link, $flag = SYMLINK_FILE) {
switch ($flag) {
case SYMLINK_DIR: $pswitch = '/d'; break;
case SYMLINK_JUNCTION: $pswitch = '/j'; break;
case SYMLINK_FILE:
default: $pswitch = ''; break;
}
// Change / to \ because it will break otherwise.
$target = str_replace('/', '\\', $target);
$link = str_replace('/', '\\', $link);
return exec('mklink ' . $pswitch . ' "' . $link . '"
"' . target . '"');
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 63.228.197.249
----
Manual Page -- http://www.php.net/manual/en/function.symlink.php
Edit -- https://master.php.net/note/edit/74411
Del: integrated -- https://master.php.net/note/delete/74411/integrated
Del: useless -- https://master.php.net/note/delete/74411/useless
Del: bad code -- https://master.php.net/note/delete/74411/bad+code
Del: spam -- https://master.php.net/note/delete/74411/spam
Del: non-english -- https://master.php.net/note/delete/74411/non-english
Del: in docs -- https://master.php.net/note/delete/74411/in+docs
Del: other reasons-- https://master.php.net/note/delete/74411
Reject -- https://master.php.net/note/reject/74411
Search -- https://master.php.net/manage/user-notes.php