John Davidson

php - File is included somewhere, how to find it?

0 comments
Message:


From my error logs I found strange file "/var/lib/php5/modules/cgi/enabled_to.php" that is included in every php file. So even if file is empty this file is included and executes.


I suppose maybe it is something from Nginx or PHP settings, but I have no idea where to look.


When I try to delete it, this error happens on all php pages:



PHP message: PHP Fatal error: Unknown: Failed opening required
'/var/lib/php5/modules/cgi/enabled_to.php'
(include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line
0" while reading response header from upstream, client: 11.11.11.11,
server: domain.com, request: "GET /url", upstream:
"fastcgi://unix:/var/run/php5-fpm.sock:", host: "host.com"



How can I trace what includes this file?



My Answer:
names being included in my PHP code. How can I find where these files are being included from?

One way to find where a file is being included from in PHP is to use the `debug_backtrace()` function. This function returns an array of information about the current execution stack, including the file and line number where a function was called.

You can use `debug_backtrace()` to trace back the inclusion of the file in question by adding it to your code and then checking the output. Here's an example:

php
// Add this code to the file you suspect is including the strange file
$backtrace = debug_backtrace();
print_r($backtrace);


This will output an array of information about the current execution stack, including the file and line number where the `debug_backtrace()` function was called. Look for the file and line number where the strange file is being included to identify where it is coming from.

Once you have identified the file that is including the strange file, you can investigate further to determine why it is being included and if it is necessary for your code.

Rate this post

3 of 5 based on 6365 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us