PHP Line Number constant
print __FILE__ . " " . __LINE__;
print __FILE__ . " " . __LINE__;
Thanks for this tip. Here is a way to automatically pepper this throughout your code:
cat program.php | sed 's/;$/; print FILE . " O.K. to line: " . LINE . "\n";/' > program-debug.php
Enjoy!
Fantastic. Now I have an include in all my pages, which can be called with: debug(); It's great!
function debug(){ echo "File:".FILE . "Line:" .LINE.""; }
the function won't work as far as I can see because it will always give you the line number of the function, not the calling code. Am I missing something?
Take a look at http://us2.php.net/manual/en/function.debug-backtrace.php this function provides more information and provides data on calling line & file
Thanks for this! I have the function set up to pass the line number to it by using a variable. I do not need the filename outputting myself.
function debug($lineno) { echo 'PHP line no: '.$lineno.''; }
debug(LINE);