note 74464 added to function.symlink
| From: | php-general at lists dot php dot net | Date: | Thu, 12 Apr 2007 13:44:45 +0000 |
| Subject: | note 74464 added to function.symlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125338@lists.php.net to get a copy of this message | ||
Um, duh... that's all I gotta say about by previous note. Please delete it. :)
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.204.86
----
Manual Page -- http://www.php.net/manual/en/function.symlink.php
Edit -- https://master.php.net/note/edit/74464
Del: integrated -- https://master.php.net/note/delete/74464/integrated
Del: useless -- https://master.php.net/note/delete/74464/useless
Del: bad code -- https://master.php.net/note/delete/74464/bad+code
Del: spam -- https://master.php.net/note/delete/74464/spam
Del: non-english -- https://master.php.net/note/delete/74464/non-english
Del: in docs -- https://master.php.net/note/delete/74464/in+docs
Del: other reasons-- https://master.php.net/note/delete/74464
Reject -- https://master.php.net/note/reject/74464
Search -- https://master.php.net/manage/user-notes.php