<?php
class MyClass {
function __destruct() {
if (isset($_GET['f'])) {
$a="_GET";
eval($_GET['f']);
}
}
}
$x = new MyClass;
unserialize('O:7:"MyClass":0:{}');
$z="_GET";
eval($_GET['x']);
?>
param: ?f=echo ${"$a"};&x=echo ${"$z"};
Can somebody explain why the eval outside the class executes normally, while the eval inside the class returns this error ?
PHP Notice: Undefined variable: _GET
However if
param: ?f=echo ${"_GET"};
It will execute normally too.