Re: get file from object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Rixham wrote:
Jack Bates wrote:
How do I get the file where a class is defined, from an instance of that
class?


you could hack around with exceptions or simply use Reflection.. it's all provided for you

$testObject = new YourClass();

$class = new ReflectionClass( get_class($testObject) );
echo $class->getFileName() . PHP_EOL;
echo $class->getStartLine() . PHP_EOL;
echo $class->getEndline() . PHP_EOL;

apologies.. see the get_class addition above; should really check code before hitting send!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux