Going through the php document I came across magic constant __LINE__.
-What this contants does?
returns the current Line No. of the file.
-How we can use this constant in development?
I started using this function for most of the debugging purposes. I simply append it with my echo messages. So when I need to go to code, I can directly go the same line.
I more magical constant I used along with __LINE__ of __FILE__. __FILE__ gives the name of the current script file name.
These two functions reduced 20% of my debugging time.
Example :
// Returns the line number of file
echo __LINE__;
Output : 21
// Returns the line number and full file name.....
echo __LINE__.of.__FILE__;
Otuput :
23 of /opt/lampp/htdocs/demos/demo.php
No comments:
Post a Comment