|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69339 realpath(false) returns CWD
Submitted: 2015-03-31 09:04 UTC Modified: 2018-10-06 11:57 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned: cmb (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.6.7 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
5 + 38 = ?
Subscribe to this entry?

 [2015-03-31 09:04 UTC]
realpath(false) returns the CWD. This is the behavior that the manual describes for blank or NULL values: "Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory."

Either this is a bug in PHP or the documented needs to be amended.

Test script:

Expected result:
string(8) "/home/sb"
string(8) "/home/sb"

Actual result:
string(8) "/home/sb"
string(8) "/home/sb"
string(8) "/home/sb"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-31 10:52 UTC]
Having a look at the implementation of realpath[1], there is
nothing special with the arguments '' or NULL happening. Actually,
realpath expects a string, so other argument types will be juggled
to string, and an empty string is treated as relative path.

That's seems to be pretty fine, so I'm changing to "Documentation
Problem". However, I'm not sure that it makes sense to document
special cases such as NULL and FALSE(or even

[1] <>
 [2015-03-31 10:53 UTC]
-Type: Bug +Type: Documentation Problem
 [2018-10-06 11:56 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #69339: realpath(false) returns CWD

There is nothing special with realpath() regarding type juggling,
so there's no need to mention that NULL can be passed instead of
an empty string.  That even wouldn't work for strict_types.
 [2018-10-06 11:57 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-10-06 11:57 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:05 UTC]
Automatic comment on behalf of cmb
Log: Fix #69339: realpath(false) returns CWD
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jun 02 09:03:36 2023 UTC