note 92657 modified in function.register-shutdown-function by danbrown
| From: | danbrown@php.net | Date: | Mon, 03 Aug 2009 16:47:41 +0000 |
| Subject: | note 92657 modified in function.register-shutdown-function by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159039@lists.php.net to get a copy of this message | ||
You definitely need to be careful about using relative paths in after the shutdown function has been
called, but the current working directory doesn't (necessarily) get changed to the web
server's ServerRoot - I've tested on two different servers and they both have their CWD
changed to '/' (which isn't the ServerRoot).
This demonstrates the behaviour:
<?php
function echocwd() { echo 'cwd: ', getcwd(), "\n"; }
register_shutdown_function('echocwd');
echocwd() and exit;
?>
Outputs:
cwd: /path/to/my/site/docroot/test
cwd: /
NB: CLI scripts are unaffected, and keep their CWD as the directory the script was called from.
--was--
You definitely need to be careful about using relative paths in after the shutdown function has been
called, but the current working directory doesn't (necessarily) get changed to the web
server's ServerRoot - I've tested on two different servers and they both have their CWD
changed to '/' (which isn't the ServerRoot).
This demonstrates the behaviour:
<?
function echocwd() { echo 'cwd: ', getcwd(), "\n"; }
register_shutdown_function('echocwd');
echocwd() and exit;
?>
Outputs:
cwd: /path/to/my/site/docroot/test
cwd: /
NB: CLI scripts are unaffected, and keep their CWD as the directory the script was called from.
http://php.net/manual/en/function.register-shutdown-function.php