Q: Can you print the name of an include as code is executed within it? I'm trying to create a little develpoment utility for myself to print queries and the name of the file they're executed within while locally working on my code.
Let's say I have this page:
<h1>Page</h1>
<?php include('file.php')?>

And file.php had a query within it
$query_clients = query('SELECT * FROM clients');
while($client = mysqli_fetch_array($query))

And function query() could optionally print the query $string
Is there a way that when the page loads, this could be the result?
<h1>Page</h1>
file.php
SELECT * FROM clients

So as query() gets executed, I could then print the file the query() function is being run from? That way I would be able to see the query that was executed, and the file it was executed within.
I realise I can use get_included_files to show all includes, but can I show the include name as it's executing?
I also don't want to have to turn the include into a string that prints, because that would required hundreds of lines of code to be changed, defeating the purpose of having a simple tool. Or having to create my own include() wrapper, like include_then_print()
__FILE__ doesn't work for me as it just prints my includes/funcitons.php file
$_SERVER["SCRIPT_NAME"] $_SERVER['PHP_SELF'] don't work as they just the current file name

A: Thank you Ruperto, this does exactly what I want
$filename = debug_backtrace(1);
echo(reset($filename[0]));

Returns
C:\[localpath]\file.php

