|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-04-28 09:30 UTC] tomaz dot lovrec at x-shells dot org
Description:
------------
When compiling a simple include_once or require_once with a part of path in it, and not just the file name, i.e. when an included files resides in a lower directory, this path gets replaced by the original source file location at compile time.
I.e. if you put your source PHP file in /var/www/htdocs/tocompile
and compile that file with "bcompile_write_header/file/footer()" and save it to /var/www/htdocs/compiled, any include/require_once(and possibly others) will try and refference files in /var/www/htdocs/tocompile.
Bellow is a simple file I've created and tested.
Reproduce code:
---------------
<? require_once('inc/test.php'); echo $test_value; ?>
Compiled with:
$fhandle = fopen(compiled/testing.php, 'w');
bcompiler_write_header($fhandle);
bcompiler_write_file($fhandle, tocompile/testing.php);
bcompiler_write_footer($fhandle);
fclose($fhandle);
Expected result:
----------------
After above compile, the compiled script should produce an error, because there was no "compiled/inc/test.php" file available.
Actual result:
--------------
After removing inc/test.php file from "tocompile" directory, it produced an error, file or directory not found with path to "tocompile/inc/test.php"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 08:00:01 2025 UTC |
It's a known problem that can't be just solved at bcompiler level, since it relates to PHP internals. I can suggest trying require_once(dirname(__FILE__).'/inc/test.php') instead of require_once('inc/test.php').