|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74823 getcwd() incorrect output in register_shutdown_function()
Submitted: 2017-06-28 09:57 UTC Modified: 2017-06-28 18:42 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: william at jwlchina dot cn Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 7.0.20 OS: ubuntu14.04
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:
29 + 40 = ?
Subscribe to this entry?

 [2017-06-28 09:57 UTC] william at jwlchina dot cn
Server: docker ubuntu14.04 
php-fpm version:7.0.15 and 7.0.20
Nginx: 1.4.6

getcwd() incorrect output in register_shutdown_function()

getcwd() returns wrong directory in register_shutdown_function(), only happens when using php-fpm or cgi. Bug not found in cli mode. 

Test script:

echo "Expected:" . getcwd() . "<br>";

register_shutdown_function(function () {
    echo "In shutdown function:" . getcwd() . "<br>";

// Output:
// Expected:/var/www/html/test
// In shutdown function:/

Expected result:
In shutdown function:/var/www/html/test

Actual result:
In shutdown function:/


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-28 18:42 UTC]
-Status: Open +Status: Not a bug
 [2017-06-28 18:42 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at
> Note:
> Working directory of the script can change inside the shutdown function under
> some web servers, e.g. Apache.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 23:01:31 2024 UTC