Hello
I have a php website. I am trying to trace (find out) which files are called when a page is displayed.
For example on certain pages that get displayed it may call up to 6-7 files. I would like to know the name of the files and the order they are called.
As through out the code there is a lot of
include_once("global/global.libs.php");
Is there any may to easily trace this without having to go through page by page on the code and try to figure out what is happening.
Essentially I just want the file name eg global/global.libs.php logged somewhere
Thanks in advance
find out which files are called
Moderator: General Moderators
-
yellowrabbit
- Forum Newbie
- Posts: 1
- Joined: Mon Feb 27, 2012 8:43 pm
Re: find out which files are called
debug_backtrace and debug_print_backtrace might also be of help.
http://www.php.net/manual/en/function.d ... ktrace.php
http://www.php.net/manual/en/function.d ... ktrace.php
http://www.php.net/manual/en/function.d ... ktrace.php
http://www.php.net/manual/en/function.d ... ktrace.php
Re: find out which files are called
Thanks for the response guys. This looks pretty promising but unfortunately I am still learning so my programming knowledge is lacking a little bit here to get the job done.
Am I suppose to pass index.php to the function or the actual include path. The above is producing no result at all actually. I'm sure there are many errors in my above code, like I said it's a learning processes. Thanks all for being digital teachers ha!
Code: Select all
<?php
// Filename is index.php
include('test_include.php');
?>
<?php
function get_current_files_path($file_name)
{
//find the current files directory
$includes = get_included_files();
$path = "";
for ($i=0; $i < count($includes); $i++)
{
$path = strstr($includes[$i], $file_name);
if ($path != false)
{
$key = $i;
break;
}
}
$path = str_replace(getcwd(), "", $includes[$key]);
$path = str_replace("\\", "/", $path);
$path = str_replace($file_name, "", $path);
$path = ltrim($path, "/");
echo $path;
}
?>
<?php
get_current_files_path('index.php');
?>