#26073 [Opn]: ob_start callback function changes cwd

From: Date: Tue, 04 Nov 2003 00:32:02 +0000
Subject: #26073 [Opn]: ob_start callback function changes cwd
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969356822@lists.php.net to get a copy of this message
ID: 26073 Updated by: sniper@php.net Reported By: php at trancer dot nl Status: Open -Bug Type: Output Control +Bug Type: Documentation problem Operating System: Debian Linux PHP Version: 4.3.3 New Comment: It's not PHP that changes the cwd but Apache. Previous Comments: ------------------------------------------------------------------------ [2003-11-01 21:29:13] php at trancer dot nl Description: ------------ A script that does file_get_contents or file in the callback function of ob_start wont work. The file_get_contents function cant open the file. <?php // Ob callback function ob($buffer) { return file_get_contents('open.txt'); } ob_start('ob'); ?> The behaviour is so because the callback sets its cwd to the root of the disk instead of the folder the script was called from. If I copy the file I want to open to my root it can open, otherwise it will throw me this error. Warning: file_get_contents(open.txt): failed to open stream: No such file or directory in /var/www/test.php on line 6 Specifying the full path works. Could be a possible bug in the callback, otherwise a documentation problem because I was unable to find it anywhere in the docs. Reproduce code: --------------- <?php // Ob callback function ob($buffer) { return file_get_contents('open.txt'); } ob_start('ob'); ?> Expected result: ---------------- The content of open.txt Actual result: -------------- Warning: file_get_contents(open.txt): failed to open stream: No such file or directory in /var/www/test.php on line 6 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26073&edit=1

« previous php.doc (#969356822) next »