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();
精彩评论