3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gs_basename($filename) { if(strpos($filename,'/') !== false){ $baseDir=dirname($filename); $basename=str_replace($baseDir,'',$filename); $basename=str_replace('/','',$basename); } else { $basename=$filename; } return $basename; } //"/dd/ww/cc/中文.test" $b=basename('/dd/ww/cc/中文.test'); echo 1 . $b.''; // will print '.test' echo ''; $c=gs_basename('/dd/ww/cc/中文.test'); echo 2 . $c; // 中文.test
based on 6ge9p
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
1.test2中文.test
Output for hhvm-3.18.5 - 3.22.0
1中文.test2中文.test