Finding the PHP File (at run time) where a Class was Defined

前端 未结 3 1492
暗喜
暗喜 2020-11-28 22:14

Is there any reflection/introspection/magic in PHP that will let you find the PHP file where a particular class (or function) was defined?

In other words, I have the

3条回答
  •  难免孤独
    2020-11-28 23:01

    if you had an includes folder, you could run a shell script command to "grep" for "class $className" by doing: $filename = ``grep -r "class $className" $includesFolder/*\ and it would return which file it was in. Other than that, i don't think there is any magic function for PHP to do it for ya.

提交回复
热议问题