php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6636 __FILE__ is destroyed after include()
Submitted: 2000-09-08 15:29 UTC Modified: 2000-09-16 16:59 UTC
From: leon at leonatkinson dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.2 OS: Linux
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: leon at leonatkinson dot com
New email:
PHP Version: OS:

 

 [2000-09-08 15:29 UTC] leon at leonatkinson dot com
I noticed that in 4.0.2 that __FILE__ loses it's value after a file is included.  This is having an impact on a lot of my legacy code that was written before include_once() was added because I use __FILE__ to make a unique variable to mark that a file has been included already.

Here's some code that demonstrates the problem:

<?
	$x++;
	
	if($x > 10)
	{
		return(FALSE);
	}
	
	print("$x: " . __FILE__ . "<br>\n");

	include("testinclude.php");

?>

It's producing:

1: /usr/local/apache/htdocs/testinclude.php
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 

Related to this is that if I switch to include_once, __FILE__ now holds the value of just "testinclude.php".
It loses it's path.

I'm not seeing this behavior in 4.0.1pl2.  I apologize for not having the time to dig into the source right now to figure out what's going on.  Hopefully someone remembers making the change that broke __FILE__.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-16 16:59 UTC] stas@php.net
fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC