|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-10-02 17:38 UTC] pegasus at vaultwiki dot org
-Summary: Fatal error: require_once/include_once
+Summary: Fatal error: require_once/include_once when using
reference
[2014-10-02 17:38 UTC] pegasus at vaultwiki dot org
[2014-10-03 19:09 UTC] nikic@php.net
[2014-10-03 19:09 UTC] nikic@php.net
-Status: Open
+Status: Closed
[2014-10-05 17:50 UTC] ab@php.net
[2016-07-20 11:40 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 07:00:02 2025 UTC |
Description: ------------ When require_once($x) is used inside a method that takes $x as an argument by reference, the following error occurs: Fatal Error: require_once(): Failed opening '0`^,' ... If ZendOpcache is enabled, only: Fatal Error: require_once Checking the value of $x on the preceding line shows the correct value, and file_exists($x) on the proceeding line shows that PHP can find the file. If we do $y = $x; require_once($y); instead, or remove the reference, then the fatal error is bypassed. However, there are cases in the full use case where it is useful to change the required file within the method, and then have external access to the new filename thanks to the reference. Some notes: In the particular cases I've tested, the files have all been inside a symlinked directory, but I doubt that is related since it works if the reference is removed. Test script: --------------- class Test { public static function load(&$file) { require_once($file); } } $file = '/path/through/symlinked/directory/to/file'; // symlink is owned by root:root with 777 permissions // target directory is owned by PHP-run-as user Test::load($file);