tags:

views:

36

answers:

1

I wanna print out script's codes after the output.

The script goes on different ways on the way it calls. So i wanna see it when script runs. is there any function that prints all script codes as the way it writed.

Example:

$foo = "bar";
$foo .= " is my bar";
function foobar()
{
// do some stuff here
}

i wanna see the codes just like this. is there a way to do this? without file_get_contents(), file(), readfile() functions?

A: 

This will print and syntax highlight the source code of the current file:

highlight_file(__FILE__);
Chris Smith
but it does not show content of included files. is there another solution?
Spelljack
Not really, no. You could parse the source code with [`token_get_all`](http://www.php.net/manual/en/function.token-get-all.php) to find the included files and then call `highlight_file` for them, but it's not particularly nice or easy!
Chris Smith
Do you need to see the entire code? Or would a stack trace showing you what methods were called in what files be sufficient?
threendib