3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySpl extends SplFileInfo { public function getExtension() { if (method_exists(parent, 'getExtension')) { echo 'parent', PHP_EOL; return parent::getExtension(); } return end(explode('.', parent::getPathname())); } } foreach (array('foo.bar', 'baz.tar.gz', '/usr/bin/php', 'foo') as $file) { $spl = new MySpl($file); var_dump($spl->getExtension()); }

preferences:
39.21 ms | 402 KiB | 5 Q