开发者

In PHP code, given an object, is it possible to locate the source file?

Within a PHP class that is part of a much larger system, the full extent of which is not readily known, is it possible to find out where the source code resides for an object that is known to my code? That is, I have a variable that is loaded with an object about which I do not know much. Given that variable, is there a way to know what source f开发者_StackOverflow社区ile to look in to find the source code for the object that is in my variable?


Sure is.

<?php
class Test {
}

$test = new Test;
$reflect = new ReflectionClass(get_class($test));
echo $reflect->getFileName();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜