How to check which php file a function is defined in?

PHP中文网
Release: 2023-03-01 08:26:01
Original
2940 people have browsed it


How to check which php file the function appearing in a certain php script is defined in? Use ReflectionFunction. ReflectionMethod Chinese Documentation ReflectionFunction Chinese Documentation

getMessage();
        return;
    }
    $start = $func->getStartLine() - 1;
    $end =  $func->getEndLine() - 1;
    $filename = $func->getFileName();
        echo "function $funcname defined by $filename($start - $end)\n";
    }
    function_dump('a');
    function_dump(array('b', 'f'));
    $b = new b();
    function_dump(array($b, 'f'));
?>
Copy after login

Use phpstorm to open the entire project, then Ctrl+click the function name to jump to the definition.

If you use an IDE, just ctrl+click with the mouse.

Use a normal editor and search the

function function name in the entire project
.Use the reflection classecho (new ReflectionFunction('function name'))->getFileName( )
The above is how to check the content of a function defined in that PHP file in PHP. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!