I have a PHP script that will allow me to track which file required it via debug_backtrace(). I wanted to auto prepend (Via auto_prepend_file within php.ini) the file so then I could build a log of the frequency in which each PHP script is ran for internal analysis.
It works fine when I create a file that requires it however it causes an error when I "auto_prepend_file" it. My understanding of auto prepend was that it will require whatever file you identify. However, the returned array of debug_backtrace appears to be empty when auto-prepending. Any ideas on what may be happening?
Code example for those curious
first.php
<?PHP
require('second.php');
?>
second.php
<?php
var_dump(debug_backtrace());
?>
For the actual auto prepending I'm just identifying second.php. When auto prepending I get:
array(0) { }
When going to first.php within the browser I get:
array(1) { [0]=> array(3) { ["file"]=> string(39) "/var/www/first.php" ["line"]=> int(4) ["function"]=> string(7) "require" } }
Any and all help is appreciated!
Thanks.