Home >Backend Development >PHP Tutorial >Problems with PHP calling position and number of lines
Now there is a situation where there is a class that can get the current row number and so on. be introduced at various locations on the page.
For example, when page A uses this acquisition method, it can get the current number of rows in which A calls this method. The same applies to pages B, C, and D.
Reply content:
For example, when page A uses this acquisition method, it can get the current number of rows in which A calls this method. The same applies to pages B, C, and D.
Please tell me how to implement it with php. Thank you
Reflection?
You can refer to:
<code>$bt = debug_backtrace(); $file = __FILE__; $line = "unkown"; if (isset($bt[0]) && isset($bt[0]['file'])) { $file = $bt[0]['file']; $line = $bt[0]['line']; } $fl= '['.$file.':'.$line.']';</code>
Please refer to magic variables
<code>__LINE__ __FUNCTION__ __CLASS__ __METHOD__</code>