一 反射的使用:
<?php<BR>class ReflectionUtil{<BR> static function getClassSource(ReflectionClass $class){<BR> $path=$class->getFileName();<BR> $lines=@file($path);<BR> $from=$class->getStartLine();<BR> $to=$class->getEndLine();<BR> $len=$to-$from+1;<BR> return implode(array_slice($lines,$from-1,$len));<BR> }<BR>}<BR>$classname="Person";<BR>$path="../practice/{$classname}.php";<BR>if(!file_exists($path)){<BR> throw new Exception("No such file as {$path}");<BR>}<BR>require_once($path);<BR>if(!class_exists($classname)){<BR> throw new Exception("No such class as {$classname}");<BR>}<BR>print ReflectionUtil::getClassSource(new ReflectionClass('Person'));<BR>?><BR>