ID: 49612 Updated by: j...@php.net -Summary: require_once include twice the same file Reported By: l dot mauri at neopost dot com -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: Solaris 10 PHP Version: 5.2.11 New Comment:
Are there any symlinks involved..? Previous Comments: ------------------------------------------------------------------------ [2009-09-21 13:04:25] l dot mauri at neopost dot com Description: ------------ Hello everyone, I have a problem with my installation of PHP 5.2.11 (please see my configuration below) I'm using require_once to include twice the same file. In one case I'm including the file based on its relative path and in other case I'm including it with its absolute path. When I use the php client in command line, it works fine. I only have the problem using Apache server. I figured out that realpath can't resolve the relative path: <?php print realpath("./file2.php") . "\n"; ==> FALSE print realpath("/absolute/path/to/file2.php') . "\n"; ==> / absolute/path/to/file2.php ?> Thank you in advance ---------------------------------------------------------------- Configuration: SunOS devs0004 5.10 Generic_137137-09 sun4u sparc SUNW,Sun-Fire-V240 64-bit sparcv9 kernel modules PHP 5.2.11 Configure Command => './configure' '--with-libxml-dir=/usr/local' '-- with-mysql=/usr/local/mysql5136/' '--enable-track-vars' '--enable- libgcc' '--enable-trans-sid' '--enable-ftp' '--enable-pcntl' '--enable- sockets' '--enable-soap' '--with-apxs=/usr/apache/bin/apxs' '--with- zlib-dir=/usr/local/lib' '--with-pdo-mysql=/usr/local/mysql5136' '-- with-mcrypt=/usr/local/bin' '--enable-debug' $ file /usr/local/bin/php /usr/local/bin/php: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped $ file /usr/apache/libexec/libphp5.so /usr/apache/libexec/libphp5.so: ELF 32-bit MSB dynamic lib SPARC Version 1, dynamically linked, not stripped Apache 1.3.41 Reproduce code: --------------- file1.php <?php require_once('./file2.php'); require_once('/absolute/path/to/file2.php'); $a = new A(); ?> ---------------------------------------------------------------- file2.php <?php class A { public function foo() { echo 'Foo'; } } ?> Expected result: ---------------- The second call to require_once does not include the file. Actual result: -------------- PHP raise a Fatal Error : "Fatal error: Cannot redeclare class" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49612&edit=1