Home > Backend Development > PHP Tutorial > Problems with PHP calling position and number of lines

Problems with PHP calling position and number of lines

WBOY
Release: 2016-08-27 09:06:48
Original
1043 people have browsed it

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.

Please tell me how to implement it with php. Thank you

Reply content:

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.


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>
Copy after login

Please refer to magic variables

<code>__LINE__
__FUNCTION__
__CLASS__
__METHOD__</code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template