php序列号可以干嘛的,php序列号和反序列化

----------------------

运行结果:

c2ffa46bfb59d32dab9a9cde6f048ca5.png

//$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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值