----------------------
运行结果:
//$a = scandir(‘/tmp/caoym_temp‘);
//foreach($a as $v) {
// if ($v == ‘.‘ || $v == ‘..‘) {
// continue;
// }
// $cont = file_get_contents("/tmp/caoym_temp/".$v);
// $b = unserialize($cont);
//
// var_dump($b);
//}
class A {
public $name = "aaaa";
public function say() {
echo $this->name;
}
}
$a = new A();
$t = serialize($a);
echo $t;
//$t = ‘O:1:"A":1:{s:4:"name";s:4:"aaaa";}‘;
$b = unserialize($t);
$b->say();
var_dump($b);
$methods = get_class_methods(get_class($b));
var_dump($methods);
$cn = ‘A‘;
$method = ‘say‘;
$func = new ReflectionMethod($cn, $method);
$f = $func->getFileName();
$start_line = $func->getStartLine() - 1;
$end_line = $func->getEndLine();
$length = $end_line - $start_line;
$source = file($f);
$source = implode(‘‘, array_slice($source, 0, count($source)));
// $source = preg_split("/(\n|\r\n|\r)/", $source);
$source = preg_split("/".PHP_EOL."/", $source);
$body = ‘‘;
for($i=$start_line; $i
$body.="{$source[$i]}\n";
echo $body;
原文:https://www.cnblogs.com/oxspirt/p/14237832.html