3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * @link http://www.php.net/manual/en/splfileinfo.getfilename.php */ $paths = array( '/path/to/', 'http://example.com/path/to/', 'http://example.com/path/' , 'http://example.com/' , 'http://' , 'http:/', ); foreach ($paths as $path) { $info = new SplFileInfo($path); printf( "%' -32s: %' -32s %' -12s %' -12s\n", $path, $info->getPathname() , $info->getBasename(), $info->getFilename() ); printf( "%' -32s %' -32s %' -12s", '', dirname($path), basename($path) ); echo "\n"; }
Output for 5.3.0 - 7.1.0
/path/to/ : /path/to to to /path to http://example.com/path/to/ : http://example.com/path/to to to http://example.com/path to http://example.com/path/ : http://example.com/path path path http://example.com path http://example.com/ : http://example.com example.com example.com http: example.com http:// : http: http: http: . http: http:/ : http: http: http: . http:
Output for 5.2.2 - 5.2.17
/path/to/ : /path/to/ /path to http://example.com/path/to/ : http://example.com/path/to/ http://example.com/path to http://example.com/path/ : http://example.com/path/ http://example.com path http://example.com/ : http://example.com/ http: example.com http:// : http:// . http: http:/ : http:/ . http:
Output for 5.1.2 - 5.2.1
Fatal error: Call to undefined method SplFileInfo::getBasename() in /in/3PBl8 on line 20
Process exited with code 255.
Output for 5.0.0 - 5.1.1
Fatal error: Class 'SplFileInfo' not found in /in/3PBl8 on line 16
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: splfileinfo in /in/3PBl8 on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: splfileinfo in /in/3PBl8 on line 16