|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2020-08-12 07:56 UTC] nikic@php.net
  [2020-08-17 21:54 UTC] crell@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Thu Oct 30 07:00:02 2025 UTC | 
Description: ------------ The list of include/require_once()'ed files seems to not persist between preloading and regular code run. Given the 3 files in the test script section, if I run the following: php -d opcache.preload=preload.php -S localhost:8080 And then view the page in a browser, I would expect to just see "A" in the output. Instead, I see: Including A A Indicating the file is really getting executed twice; once in preload, once in the page request. However, there's no error about the function already being defined. The "Including A" line is shown on the console when the server starts, indicating it is preloading the file. If I remove the require_once() from index.php, the code still runs, confirming it is getting preloaded. I don't entirely understand how that combination of results can happen, as it implies the file is being executed twice but not dying on the already-declared function. Test script: --------------- <?php # a.php print "Including A" . PHP_EOL; function a() { print "A" . PHP_EOL; } ?> <?php # preload.php require_once('a.php'); ?> <?php # index.php header('content-type: text/plain'); require_once('a.php'); a(); ?> Expected result: ---------------- The behavior I would expect is that a file require_once()ed in preload would get skipped entirely if require_once()ed again in the main application. That way, I'd be able to have my application require_once() all of the non-autoloadable files it needs, but then still toss all of that into preloading for production and have it just "get faster." Whatever is happening in those files should only happen the one time, period.