php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36454 Destructor, include/require and path with "./"
Submitted: 2006-02-19 20:05 UTC Modified: 2007-01-22 23:12 UTC
Votes:40
Avg. Score:4.7 ± 0.8
Reproduced:26 of 28 (92.9%)
Same Version:18 (69.2%)
Same OS:19 (73.1%)
From: nightstorm at tlen dot pl Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.1.2 OS: Windows XP
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nightstorm at tlen dot pl
New email:
PHP Version: OS:

 

 [2006-02-19 20:05 UTC] nightstorm at tlen dot pl
Description:
------------
In the reproduce code we include a file "test.php" showing 'Hello World' six times:
 - Outside a destructor: "test.php"
 - Outside a destructor: "D:\server\www\test\test.php" (full path)
 - Outside a destructor: "./test.php"

These three cases work. We don't change include path and try them in a destructor:
 - Outside a destructor: "test.php" - works
 - Outside a destructor: "D:\server\www\test\test.php" (full path) - works
 - Outside a destructor: "./test.php" - No such file or directory, even if the file exists.

Outside a destructor, PHP parses correctly the include path, inside it seems to be broken, because a fatal error is generated. PHP manual doesn't explain why the last case doesn't work, I also can't find any reason. I hope you'll fix it quickly.

---Configuration---
Windows XP SP 2 (NTFS)
PHP 5.1.2
Apache 2.0.55
Ze1.compatibility = 0
Include path = .;C:\php5\pear (PHP 5 default)
Safe mode = off

Reproduce code:
---------------
test.php:
<?php
	echo 'Hello world!<br/>';
?>

problem.php:
<?php	
	require('test.php');
	require('D:\server\www\test\test.php');
	require('./test.php');

	class foo{
		function __destruct()
		{
			require('test.php');
			require('D:\server\www\test\test.php');
			require('./test.php');
		}
	}
	
	$foo = new foo;
?>

Expected result:
----------------
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!

Actual result:
--------------
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!

Warning: foo::require(./test.php) [function.require]: failed to open stream: No such file or directory in D:\server\www\test\problem.php on line 11

Fatal error: foo::require() [function.require]: Failed opening required './test.php' (include_path='.;C:\php5\pear') in D:\server\www\test\problem.php on line 11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-10 12:55 UTC] sniper@php.net
It's because of Apache which changes the current working dir at some point(s). Not PHP bug to be fixed.
 [2007-01-22 23:12 UTC] didou@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Dup of #34206
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 10:01:32 2024 UTC