Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7898095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:20:28+00:00 2026-06-03T08:20:28+00:00

I have a symlink on my Windows server which was made like this: F:\>mkdir

  • 0

I have a symlink on my Windows server which was made like this:

F:\>mkdir link-target
F:\>mklink /D link f:\link-target 

(Note the lower case f: in the symlink target)

In PHP I run this:

$dir = realpath('f:\link');
var_dump($dir);

$dir = realpath($dir);
var_dump($dir);

Which outputs:

string 'f:\link-target' (length=14)
string 'F:\link-target' (length=14)

Notice the change in case on the second realpath.

Is this a bug, or intended? And whats the best way to work around it?

It is breaking a case like this:

function check_link($to, $from) {
    if (realpath($to) !== realpath($from)) {
        ...
    }
}

Which is used to check $to exists, and is linked to $from.

  • PHP 5.4
  • Windows 7

Edit:

I need consistent behavior on both Windows and Linux, and have the following work around be its pretty nasty:

if (realpath($from) === false) {
} elseif (realpath($to) === false) {
} else {
    do {
        $to = realpath($to);
    } while (realpath($to) !== false && $to !== realpath($to));
    do {
        $from = realpath($from);
    } while (realpath($from) !== false && $from !== realpath($from));
    if ($to !== $from) {
        ...
    }
}

Edit 2:

On furter investigation I have noticed that on Windows symlinks are only followed 1 level deep:

// F:\>mkdir link-target
// F:\>mklink /D link f:\link-target 
// F:\>mklink /D link2 f:\link

$dir = realpath('f:\link2');
var_dump($dir);

$dir = realpath($dir);
var_dump($dir);

$dir = realpath($dir);
var_dump($dir);

// string 'f:\link' (length=7)
// string 'f:\link-target' (length=14)
// string 'F:\link-target' (length=14)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:20:30+00:00Added an answer on June 3, 2026 at 8:20 am

    Turns out

    do {
        $to = realpath($to);
    } while (realpath($to) !== false && $to !== realpath($to));
    

    is the only way.

    https://bugs.php.net/bug.php?id=61933

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file system structure with symlinks, something like this: folder123 index.php config.php
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a symlink in our website called index.php which points to a script
I have been following this link Android kernel compile and test with Android Emulator
Windows 6 (Vista and Server 2008) support proper symbolic links, which can be created
I have a directory with several dot files. I would like to symlink all
If I have a python script that is executed via a symlink, is there
I have some symlinks in my git repo which I work on from two
I have a folder with some dotfiles I would like to make symlinks for.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.