|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 04:00:01 2025 UTC |
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.