PHP Line Number constant  

PHP has a constant for the current line number, and the current filename. Useful for debugging as you can pepper them through your code and see where it stops working.

Code:

print __FILE__ . " " . __LINE__;
Leave A Reply - 2 Replies
Replies
Blaster_Boy 2008-08-28 09:30am - No Email - Logged IP: 98.172.25.66
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!
Steven 2008-09-10 01:45pm - No Email - Logged IP: 78.143.208.155
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__."
";
}
All content licensed under the Creative Commons License