|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43248 backward compatibility break in realpath()
Submitted: 2007-11-11 19:09 UTC Modified: 2007-11-13 09:47 UTC
From: carsten_sttgt at gmx dot de Assigned: dmitry (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.2.5 OS: Windows_NT
Private report: No CVE-ID: None
 [2007-11-11 19:09 UTC] carsten_sttgt at gmx dot de

regarding Bug #42778, I think should give a better explanation, why there was a break in backward compatibility in the function realpath() on windows between PHP 5.2.3 and 5.2.4, without any information in the manual or changelog.

Additional, in the manual you can read:
| The resulting path will have no symbolic link,
| '/./' or '/../' components.

A "/./" as last component in a path, is the same as "/" as last component. And thus the last "/" must be removed.

As you can see, the results with PHP 4.4.7(Win), PHP <=5.2.3(Win) and PHP 5.2.5(FreeBSD) are the same and like descriped in the manual.

Only with PHP >=5.2.3(Win) you have a different result.

The DirectoryIterator also have the same behaviour with all OS and versions.

(BTW: With Perl or VBS I have also no trailing slash on Windows)


BTW: You should not forget:
For an PHP programer it's necessary, to have the same results in PHP functions between PHP versions and operating systems. (especially without informations)

Reproduce code:
Testscripts are executed with (in the given dirs):
$ .\php -n test.php

Testscript 1 in C:\php5
  echo realpath('extras\\mibs\\');

Testscript 2 in C:\php4
  echo realpath('extras\\mibs\\');

Testscript 3 in C:\php5
  $dir = new DirectoryIterator('extras\\mibs\\');
  echo $dir->getRealPath();

Testscripts are executed with (in the given dirs):
$ ./php -n test.php

Testscript 4 in /usr/local/bin (with FreeBSD)
  echo realpath('../include/');

Testscript 5 in /usr/local/bin (with FreeBSD)
  $dir = new DirectoryIterator('../include/');
  echo $dir->getRealPath();

Expected result:
on Windows with PHP5:

on Windows with PHP4:

on FreeBSD:

Actual result:
Testscript 1 with PHP 5.2.3:

Testscript 2 with PHP 4.4.7 (Win):

Testscript 1 with PHP 5.2.4 (Win):

Testscript 1 with PHP 5.2.5 (Win):

Testscript 3 with PHP 5.2.5 (Win):

Testscript 4 with PHP 5.2.5 (FreeBSD):

Testscript 5 with PHP 5.2.5 (FreeBSD):


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-13 09:47 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 15:01:29 2024 UTC