|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64927 realpath() still returns current path on Null/false argument
Submitted: 2013-05-27 07:42 UTC Modified: 2015-04-27 04:59 UTC
From: myustc at 163 dot com Assigned: sobak (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3.25 OS: Mac OS X 10.6.8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: myustc at 163 dot com
New email:
PHP Version: OS:


 [2013-05-27 07:42 UTC] myustc at 163 dot com
From manual page:

I'm using PHP 5.3.15 (cli) (built: Jul 31 2012 18:42:11).
When I'm tracking a bug in Yii, I realized that it's the issue of php function realpath().
the reproducing is very easy, just run this in console:

php -r "var_dump(realpath(false), realpath(null), realpath(''));"

Test script:


Expected result:
I should see output as below:


Actual result:
output:(the actual path depends)

string(22) "/Users/yaowenh/phpunit"
string(22) "/Users/yaowenh/phpunit"
string(22) "/Users/yaowenh/phpunit"


changelog (last revision 2015-04-23 21:13 UTC by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-27 07:48 UTC] earlchaos at gmail dot com
I don't see the problem here?

From the manual:


    The path being checked.


        Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory.
 [2013-05-28 07:12 UTC] myustc at 163 dot com
Sorry, I meant the Changelog part:

5.0.0	 Prior to this release, a blank or NULL path would cause realpath() to return the directory name of the script.

which sounds to me as if such behavior was removed since 5.0.0. Correct me if I'm wrong...
 [2013-05-29 18:47 UTC] Sjon at hortensius dot net
It seems that Changelog notice is incorrect; see The only 
difference is that since 5.2 the cwd is returned
 [2015-04-23 21:13 UTC]
-Status: Open +Status: Verified
 [2015-04-23 21:13 UTC]
The PHP 5.0.0 changelog entry has been removed in the meantime. However, the behavioral change in PHP 5.2.1 pointed out by Sjon is not yet documented.
 [2015-04-23 21:13 UTC]
The following patch has been added/updated:

Patch Name: changelog
Revision:   1429823637
 [2015-04-27 04:58 UTC]
Automatic comment from SVN on behalf of sobak
Log: Apply patch by Christoph Michael Becker (closes bug #64927)
 [2015-04-27 04:59 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: sobak
 [2015-04-27 04:59 UTC]
Thanks, Christoph! Closed.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Jun 04 21:03:39 2023 UTC