Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- Test extract() with $this --FILE-- <?php class Extract { public function run..
Decoded Output download
--TEST--
Test extract() with $this
--FILE--
<?php
class Extract
{
public function run(): void
{
$options = [
'EXTR_OVERWRITE' => EXTR_OVERWRITE,
'EXTR_SKIP' => EXTR_SKIP,
'EXTR_PREFIX_SAME' => EXTR_PREFIX_SAME,
'EXTR_PREFIX_ALL' => EXTR_PREFIX_ALL,
'EXTR_PREFIX_INVALID' => EXTR_PREFIX_INVALID,
'EXTR_IF_EXISTS' => EXTR_IF_EXISTS,
'EXTR_PREFIX_IF_EXISTS' => EXTR_PREFIX_IF_EXISTS,
];
foreach ($options as $name => $flags) {
echo "{$name}
";
$this->handle($name, $flags);
$this->handle("{$name}_REFS", $flags | EXTR_REFS);
echo "
";
}
}
private function handle(string $name, int $flags): void
{
$array = ["this" => "value"];
try {
$result = extract($array, $flags, "x");
echo " extract() = {$result}
";
echo " \$this = " . get_class($this) . "
";
echo " \$v_this = " . (isset($x_this) ? $x_this : "NULL") . "
";
} catch (\Throwable $e) {
echo " Exception: " . $e->getMessage() . "
";
}
}
}
(new Extract)->run();
?>
--EXPECT--
EXTR_OVERWRITE
Exception: Cannot re-assign $this
Exception: Cannot re-assign $this
EXTR_SKIP
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
EXTR_PREFIX_SAME
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_PREFIX_ALL
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_PREFIX_INVALID
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_IF_EXISTS
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
EXTR_PREFIX_IF_EXISTS
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
Did this file decode correctly?
Original Code
--TEST--
Test extract() with $this
--FILE--
<?php
class Extract
{
public function run(): void
{
$options = [
'EXTR_OVERWRITE' => EXTR_OVERWRITE,
'EXTR_SKIP' => EXTR_SKIP,
'EXTR_PREFIX_SAME' => EXTR_PREFIX_SAME,
'EXTR_PREFIX_ALL' => EXTR_PREFIX_ALL,
'EXTR_PREFIX_INVALID' => EXTR_PREFIX_INVALID,
'EXTR_IF_EXISTS' => EXTR_IF_EXISTS,
'EXTR_PREFIX_IF_EXISTS' => EXTR_PREFIX_IF_EXISTS,
];
foreach ($options as $name => $flags) {
echo "{$name}\n";
$this->handle($name, $flags);
$this->handle("{$name}_REFS", $flags | EXTR_REFS);
echo "\n";
}
}
private function handle(string $name, int $flags): void
{
$array = ["this" => "value"];
try {
$result = extract($array, $flags, "x");
echo " extract() = {$result}\n";
echo " \$this = " . get_class($this) . "\n";
echo " \$v_this = " . (isset($x_this) ? $x_this : "NULL") . "\n";
} catch (\Throwable $e) {
echo " Exception: " . $e->getMessage() . "\n";
}
}
}
(new Extract)->run();
?>
--EXPECT--
EXTR_OVERWRITE
Exception: Cannot re-assign $this
Exception: Cannot re-assign $this
EXTR_SKIP
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
EXTR_PREFIX_SAME
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_PREFIX_ALL
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_PREFIX_INVALID
extract() = 1
$this = Extract
$v_this = value
extract() = 1
$this = Extract
$v_this = value
EXTR_IF_EXISTS
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
EXTR_PREFIX_IF_EXISTS
extract() = 0
$this = Extract
$v_this = NULL
extract() = 0
$this = Extract
$v_this = NULL
Function Calls
None |
Stats
MD5 | 0f523316ff006b651bcb3d08b126f9ff |
Eval Count | 0 |
Decode Time | 90 ms |