php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17551 PHP4.10 and PHP4.20 includes different files when calling include_once()
Submitted: 2002-05-31 23:48 UTC Modified: 2002-06-04 01:53 UTC
From: ulysses at mail dot fitan dot com dot tw Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.0 OS: Windows 2000 (IIS5.0)
Private report: No CVE-ID: None
 [2002-05-31 23:48 UTC] ulysses at mail dot fitan dot com dot tw
I found the PHP4.10 and PHP4.20 use different ways to 
handle relative path when calling include_once(). Here is 
an example. Consider the following file structure:

c:/inetpub/wwwroot/test/a.php
c:/inetpub/wwwroot/test/inc/b.php
c:/inetpub/wwwroot/test/cls/c.php
c:/inetpub/wwwroot/test/inc/cls/c.php

test/a.php:
<?
echo "<BR>now in ".__FILE__;
include_once("inc/b.php");
?>

test/inc/b.php:
<?
echo "<BR>now in ".__FILE__;
include_once("cls/c.php");
?>

test/cls/c.php and test/inc/cls/c.php
<?
echo "<BR>now in ".__FILE__;
?>


PHP 4.10 shows this result:
now in c:/inetpub/wwwroot/test/a.php
now in c:/inetpub/wwwroot/test/inc/b.php
now in c:/inetpub/wwwroot/test/cls/c.php

But PHP4.20 shows this result:
now in c:/inetpub/wwwroot/test/a.php
now in c:/inetpub/wwwroot/test/inc/b.php
now in c:/inetpub/wwwroot/test/inc/cls/c.php

I did not found related announcement in the 4.20 and 4.21 
release notes, so I think it is a bug (or at least an 
incompatiable issue.)

Here are my php.ini settings (in both 4.10 and 4.20):
1. Enable register_globals
2. Disable magic_quote_gpc
3. Change execution time limit to 60sec
4. Change max memory limit to 12MB
5. Change default_charset to big5
6. Change doc_root to c:/inetpub/wwwroot
7. Enable MSSQL extension
8. Disable cgi.force-redirect (in PHP4.20)
9. Install ZendOptimizer

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-01 09:38 UTC] sniper@php.net
For me it looks like 4.2.x works as expected.. __FILE__
outputs the correct path there.


 [2002-06-01 09:39 UTC] sniper@php.net
For me it looks like 4.2.x works as expected.. __FILE__
outputs the correct path there.


 [2002-06-02 23:15 UTC] ulysses at mail dot fitan dot com dot tw
I am not playing with PHP. It my job and I am developing a 
Stock-MRP-Accounting system for my client and I have 
problems switching from 4.10 to 4.20. Maybe I should 
describe the real situation to you.

I have these files:

c:/inetpub/wwwroot/stock/stock_amend.php
c:/inetpub/wwwroot/stock/edit/stock_amend.approve.php
c:/inetpub/wwwroot/stock/class/notification.class.php

1. The stock_amend.php is the main entrance. When user 
invoke stock_amend.php with POST, stock_amend.php will 
call:

include_once('edit/stock_amend.approve.php')

to execute authorization and data modifications. 

2. In edit/stock_amend.approve.php program will 
conditionally calling 

include_once('class/notification.class.php');

to make logs.

Now the problem is, these codes works fine on my developing 
platform (PHP4.10), but they failed to work on my client's 
server (PHP4.20). I've got this message:

Warning: Failed opening 'class/notification.class.php' for 
inclusion (include_path='c:\php4\pear') in c:/inetpub/
wwwroot/stock/edit/stock_amend.approve.php
 on line 105

Now I rewrite my experimental codes:

c:/inetpub/wwwroot/test/a.php
c:/inetpub/wwwroot/test/inc/b.php
c:/inetpub/wwwroot/test/cls/c.php
c:/inetpub/wwwroot/test/inc/cls/c.php



test/a.php:
<?
echo "<BR>I'm a.php (".__FILE__.")";
include_once("inc/b.php");
?>

test/inc/b.php:
<?
echo "<BR>I'm b.php (".__FILE__.")";
include_once("cls/c.php");
?>

test/cls/c.php:
<?
echo "<BR>I'm CORRECT c.php (".__FILE__.")";
?>

test/inc/cls/c.php:
<?
echo "<BR>I'm WRONG c.php (".__FILE__.")";
?>

PHP 4.10 shows this result:

I'm a.php (c:/inetpub/wwwroot/test/a.php)
I'm b.php (c:/inetpub/wwwroot/test/inc/b.php)
I'm CORRECT c.php (c:/inetpub/wwwroot/test/cls/c.php)


But PHP4.20 shows this result:

I'm a.php (c:/inetpub/wwwroot/test/a.php)
I'm b.php (c:/inetpub/wwwroot/test/inc/b.php)
I'm WRONG c.php (c:/inetpub/wwwroot/test/inc/cls/c.php)


Of course I know that I can use full path in include_once() 
to prevent this problem. The point is: PHP4.10 AND PHP4.20 
DID INCLUDE DIFFERENT FILES AND I AM NOT TALKING ABOUT 
__FILE__. There is nothing wrong with __FILE__ in 4.10 and 
4.20. They all present the correct file path.
 [2002-06-03 06:18 UTC] mfischer@php.net
Works as expected for me (though 4.1.2 seems to be broken):

4.0.6
I'm a.php (a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />

4.1.0
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />

4.1.1
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />

4.1.2
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm WRONG c.php (C:\Inetpub\wwwroot\php\test\inc\cls\c.php)<br />

4.2.0
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />

4.2.1
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />

4.3.0-dev
I'm a.php (C:\Inetpub\wwwroot\php\test\a.php)<br />
I'm b.php (C:\Inetpub\wwwroot\php\test\inc\b.php)<br />
I'm CORRECT c.php (C:\Inetpub\wwwroot\php\test\cls\c.php)<br />
 [2002-06-03 07:01 UTC] mfischer@php.net
And hera again the same with IIS/CGI (the former was from the command line). There's no difference, I suspect this being a configuration problem with your system, please ask for support at php-general@lists.php.net

4.0.6
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

4.1.0
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

4.1.1
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

4.1.2
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm WRONG c.php (c:\inetpub\wwwroot\php\test\inc\cls\c.php)

4.2.0
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

4.2.1
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

4.3.0-dev
I'm a.php (c:\inetpub\wwwroot\php\test\a.php)
I'm b.php (c:\inetpub\wwwroot\php\test\inc\b.php)
I'm CORRECT c.php (c:\inetpub\wwwroot\php\test\cls\c.php)

 [2002-06-03 21:34 UTC] ulysses at mail dot fitan dot com dot tw
Thank you. I'll ask for support.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 22:01:26 2024 UTC