- register_shutdown_function: documentation ( source)
- unlink: documentation ( source)
- file_put_contents: documentation ( source)
<?php
class Test {
function run() {
$file = __FILE__ . '.tmp';
register_shutdown_function(function () use ($file) { @unlink($file); });
file_put_contents($file, '<?php self::foo(); ?>');
require $file;
}
static function foo() { echo 'Hi!', PHP_EOL; }
}
(new Test)->run();