- var_dump: documentation ( source)
- end: documentation ( source)
- explode: documentation ( source)
- method_exists: documentation ( source)
<?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());
}