php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42778 realpath() adds trailing slash
Submitted: 2007-09-27 13:49 UTC Modified: 2007-10-02 09:33 UTC
From: k dot bizuns at inbox dot lv Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 5.2.4 OS: Windows
Private report: No CVE-ID:
 [2007-09-27 13:49 UTC] k dot bizuns at inbox dot lv
Description:
------------
<?php
	echo realpath( './' ) ;
?>

This code in PHP 5.2.4 gives an output with trailing slash (example: C:\www\)
PHP 5.2.3 not (example: C:\www).

Who is right? Tested on WinXP.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-02 09:33 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2010-06-11 09:31 UTC] php dot net at digilog dot de
Does it really make sense that this function behaves so inconsistently about its 
trailing slashes between Linux and Win?:

LINUX (tested with PHP 5.2.11):
---
realpath('.')
: string = "/myhttpdfolder" 
realpath('./')
: string = "/myhttpdfolder" 
realpath('fileadmin')
: string = "/myhttpdfolder/fileadmin" 
realpath('fileadmin/')
: string = "/myhttpdfolder/fileadmin" 

WINDOWS (tested with PHP 5.2.5):
---
realpath('.')
: string = "C:\\myhttpdfolder" 
realpath('./')
: string = "C:\\myhttpdfolder\\" 
realpath('fileadmin')
: string = "C:\\myhttpdfolder\\fileadmin" 
realpath('fileadmin/')
: string = "C:\\myhttpdfolder\\fileadmin\\"
 [2011-04-01 09:48 UTC] dennis dot claassens at gmail dot com
The fact that this function does not have a consistent result means that we will have to rewrite it (in php). Wouldn't it be a lot better to make sure the behaviour of the function (yes or no trailing slash) is a fact instead of an unknown?
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 10:02:10 2014 UTC