|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-07-26 10:12 UTC] tomkrawc at gmail dot com
Description:
------------
Neighter is_link nor DirectoryIterator->isLink are not distinguish symlinks created with os command mklink. Os is showing them:
2015-07-26 09:23 <DIR> .
2015-07-26 09:23 <DIR> ..
2015-05-23 20:55 <DIR> _backup
2015-05-23 20:55 <DIR> _logi
2015-07-26 09:23 <DIR> fileadmin
2015-07-26 08:39 <SYMLINKD> typo3 [typo3_src\typo3]
2015-07-26 08:39 <SYMLINKD> typo3_src [..\typo3_src-6.2.14]
2015-07-26 09:23 <DIR> typo3conf
2015-07-26 09:23 <DIR> typo3temp
2015-07-26 09:23 <DIR> uploads
2015-05-24 10:12 5 199 .htaccess
2015-04-14 20:03 113 index.html
2015-07-26 08:39 <SYMLINK> index.php [typo3_src\index.php]
2015-05-23 18:40 19 pi.php
My env is Win 7 x64, WAMP (Apache 2.4.9, PHP 5.5.12 Thread Safe).
Test script:
---------------
if ($handle = opendir($dir)) {
echo "Directory handle: $handle\n";
echo "Entries:\n";
while (false !== ($entry = readdir($handle))) {
if (is_link($dir . $entry)) {
$strTarget = readlink($entry);
echo '>>LINK<<: ' . $entry . ' => ' . $strTarget . "\n";
}
elseif (is_file($dir . $entry)) {
echo 'File: ' . $entry . "\n";
}
elseif (is_dir($dir . $entry)) {
echo 'Dir: ' . $entry . "\n";
}
else {
echo "? - $entry\n";
}
}
closedir($handle);
}
Expected result:
----------------
both of those methods should return true
Actual result:
--------------
both of those methods should return false
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 16:00:01 2025 UTC |
Wrote this and my Win 8.1 with PHPs 5.4.29, 5.5.13, 5.6.11 don't reproduce: is_file says no, is_dir and is_link say yes. Note that you will probably need an elevated command prompt to run mklink. <?php $tempnam = tempnam(sys_get_temp_dir(), "php"); unlink($tempnam); // tempnam created a file // expecting to see "symbolic link created for %s <<===>> C:\" // - /d to create a directory symlink // - /j to create a junction passthru("mklink /d " . escapeshellarg($tempnam) . " C:\\"); clearstatcache(); if (file_exists($tempnam)) { echo "Created directory {$tempnam}\n"; echo "- is_file: ", (is_file($tempnam) ? "yes" : "no"), "\n"; echo "- is_dir: ", (is_dir($tempnam) ? "yes" : "no"), "\n"; echo "- is_link: ", (is_link($tempnam) ? "yes" : "no"), "\n"; rmdir($tempnam) or printf("Failed to remove directory\n"); } else { echo "Directory {$tempnam} does not exist\n"; } ?>