但凡是一個合格的PHP程序員
說個例子
<?php
$string =
$result = unserialize($string)
var_dump($result)
/*
object(__PHP_Incomplete_Class)[
public
public
public
*/
?>當我們反序列化一個對象時
The script tried to execute a method or access a property of an incomplete object
這不是什麼難事兒
<?php
$string =
$result = (array)unserialize($string)
var_dump($result)
/*
array
*/
?>
不過如果系統激活了Autoload
<?php
spl_autoload_register(function($name) {
var_dump($name)
})
$string =
$result = (array)unserialize($string)
var_dump($result)
?>執行上面代碼會發現
<?php
spl_autoload_register(function($name) {
include “/path/to/{$name}
})
$string =
$result = (array)unserialize($string)
var_dump($result)
?>
毫無疑問
<?php
spl_autoload_register(function($name) {
include “/path/to/{$name}
})
class Foobar {} // Oh
$string =
$result = (array)unserialize($string)
var_dump($result)
?>不得不說
<?php
spl_autoload_register(function($name) {
include “/path/to/{$name}
})
$string =
$functions = spl_autoload_functions()
foreach ($functions as $function) {
spl_autoload_unregister($function)
}
$result = (array)unserialize($string)
foreach ($functions as $function) {
spl_autoload_register($function)
}
var_dump($result)
?>代碼雖然多了點
From:http://tw.wingwit.com/Article/program/PHP/201311/21138.html