1--TEST-- 2Testing basename() with various values for the suffix parameter 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip non-windows only test'); 7} 8?> 9--FILE-- 10<?php 11 12$paths = array ( 13 14 "foo", 15 "foo/", 16 "foo\\", 17 "foo.bar", 18 "foo.bar/", 19 "foo.bar\\", 20 "dir/foo.bar", 21 "dir\\foo.bar", 22 "dir with spaces/foo.bar", 23 "dir with spaces\\foo.bar", 24 25); 26 27$suffixes = array ( 28 29 ".bar", 30 ".b", 31 ".", 32 " ", 33 "foo", 34 "foo.bar", 35 "foo/bar", 36 "foo\\bar", 37 "/", 38 "\\", 39); 40 41foreach ($paths as $path) { 42 foreach ($suffixes as $suffix) { 43 echo "basename for path $path, supplying suffix $suffix is:\n"; 44 var_dump(basename($path, $suffix)); 45 } 46} 47 48echo "\ndone\n"; 49 50?> 51--EXPECT-- 52basename for path foo, supplying suffix .bar is: 53string(3) "foo" 54basename for path foo, supplying suffix .b is: 55string(3) "foo" 56basename for path foo, supplying suffix . is: 57string(3) "foo" 58basename for path foo, supplying suffix is: 59string(3) "foo" 60basename for path foo, supplying suffix foo is: 61string(3) "foo" 62basename for path foo, supplying suffix foo.bar is: 63string(3) "foo" 64basename for path foo, supplying suffix foo/bar is: 65string(3) "foo" 66basename for path foo, supplying suffix foo\bar is: 67string(3) "foo" 68basename for path foo, supplying suffix / is: 69string(3) "foo" 70basename for path foo, supplying suffix \ is: 71string(3) "foo" 72basename for path foo/, supplying suffix .bar is: 73string(3) "foo" 74basename for path foo/, supplying suffix .b is: 75string(3) "foo" 76basename for path foo/, supplying suffix . is: 77string(3) "foo" 78basename for path foo/, supplying suffix is: 79string(3) "foo" 80basename for path foo/, supplying suffix foo is: 81string(3) "foo" 82basename for path foo/, supplying suffix foo.bar is: 83string(3) "foo" 84basename for path foo/, supplying suffix foo/bar is: 85string(3) "foo" 86basename for path foo/, supplying suffix foo\bar is: 87string(3) "foo" 88basename for path foo/, supplying suffix / is: 89string(3) "foo" 90basename for path foo/, supplying suffix \ is: 91string(3) "foo" 92basename for path foo\, supplying suffix .bar is: 93string(4) "foo\" 94basename for path foo\, supplying suffix .b is: 95string(4) "foo\" 96basename for path foo\, supplying suffix . is: 97string(4) "foo\" 98basename for path foo\, supplying suffix is: 99string(4) "foo\" 100basename for path foo\, supplying suffix foo is: 101string(4) "foo\" 102basename for path foo\, supplying suffix foo.bar is: 103string(4) "foo\" 104basename for path foo\, supplying suffix foo/bar is: 105string(4) "foo\" 106basename for path foo\, supplying suffix foo\bar is: 107string(4) "foo\" 108basename for path foo\, supplying suffix / is: 109string(4) "foo\" 110basename for path foo\, supplying suffix \ is: 111string(3) "foo" 112basename for path foo.bar, supplying suffix .bar is: 113string(3) "foo" 114basename for path foo.bar, supplying suffix .b is: 115string(7) "foo.bar" 116basename for path foo.bar, supplying suffix . is: 117string(7) "foo.bar" 118basename for path foo.bar, supplying suffix is: 119string(7) "foo.bar" 120basename for path foo.bar, supplying suffix foo is: 121string(7) "foo.bar" 122basename for path foo.bar, supplying suffix foo.bar is: 123string(7) "foo.bar" 124basename for path foo.bar, supplying suffix foo/bar is: 125string(7) "foo.bar" 126basename for path foo.bar, supplying suffix foo\bar is: 127string(7) "foo.bar" 128basename for path foo.bar, supplying suffix / is: 129string(7) "foo.bar" 130basename for path foo.bar, supplying suffix \ is: 131string(7) "foo.bar" 132basename for path foo.bar/, supplying suffix .bar is: 133string(3) "foo" 134basename for path foo.bar/, supplying suffix .b is: 135string(7) "foo.bar" 136basename for path foo.bar/, supplying suffix . is: 137string(7) "foo.bar" 138basename for path foo.bar/, supplying suffix is: 139string(7) "foo.bar" 140basename for path foo.bar/, supplying suffix foo is: 141string(7) "foo.bar" 142basename for path foo.bar/, supplying suffix foo.bar is: 143string(7) "foo.bar" 144basename for path foo.bar/, supplying suffix foo/bar is: 145string(7) "foo.bar" 146basename for path foo.bar/, supplying suffix foo\bar is: 147string(7) "foo.bar" 148basename for path foo.bar/, supplying suffix / is: 149string(7) "foo.bar" 150basename for path foo.bar/, supplying suffix \ is: 151string(7) "foo.bar" 152basename for path foo.bar\, supplying suffix .bar is: 153string(8) "foo.bar\" 154basename for path foo.bar\, supplying suffix .b is: 155string(8) "foo.bar\" 156basename for path foo.bar\, supplying suffix . is: 157string(8) "foo.bar\" 158basename for path foo.bar\, supplying suffix is: 159string(8) "foo.bar\" 160basename for path foo.bar\, supplying suffix foo is: 161string(8) "foo.bar\" 162basename for path foo.bar\, supplying suffix foo.bar is: 163string(8) "foo.bar\" 164basename for path foo.bar\, supplying suffix foo/bar is: 165string(8) "foo.bar\" 166basename for path foo.bar\, supplying suffix foo\bar is: 167string(8) "foo.bar\" 168basename for path foo.bar\, supplying suffix / is: 169string(8) "foo.bar\" 170basename for path foo.bar\, supplying suffix \ is: 171string(7) "foo.bar" 172basename for path dir/foo.bar, supplying suffix .bar is: 173string(3) "foo" 174basename for path dir/foo.bar, supplying suffix .b is: 175string(7) "foo.bar" 176basename for path dir/foo.bar, supplying suffix . is: 177string(7) "foo.bar" 178basename for path dir/foo.bar, supplying suffix is: 179string(7) "foo.bar" 180basename for path dir/foo.bar, supplying suffix foo is: 181string(7) "foo.bar" 182basename for path dir/foo.bar, supplying suffix foo.bar is: 183string(7) "foo.bar" 184basename for path dir/foo.bar, supplying suffix foo/bar is: 185string(7) "foo.bar" 186basename for path dir/foo.bar, supplying suffix foo\bar is: 187string(7) "foo.bar" 188basename for path dir/foo.bar, supplying suffix / is: 189string(7) "foo.bar" 190basename for path dir/foo.bar, supplying suffix \ is: 191string(7) "foo.bar" 192basename for path dir\foo.bar, supplying suffix .bar is: 193string(7) "dir\foo" 194basename for path dir\foo.bar, supplying suffix .b is: 195string(11) "dir\foo.bar" 196basename for path dir\foo.bar, supplying suffix . is: 197string(11) "dir\foo.bar" 198basename for path dir\foo.bar, supplying suffix is: 199string(11) "dir\foo.bar" 200basename for path dir\foo.bar, supplying suffix foo is: 201string(11) "dir\foo.bar" 202basename for path dir\foo.bar, supplying suffix foo.bar is: 203string(4) "dir\" 204basename for path dir\foo.bar, supplying suffix foo/bar is: 205string(11) "dir\foo.bar" 206basename for path dir\foo.bar, supplying suffix foo\bar is: 207string(11) "dir\foo.bar" 208basename for path dir\foo.bar, supplying suffix / is: 209string(11) "dir\foo.bar" 210basename for path dir\foo.bar, supplying suffix \ is: 211string(11) "dir\foo.bar" 212basename for path dir with spaces/foo.bar, supplying suffix .bar is: 213string(3) "foo" 214basename for path dir with spaces/foo.bar, supplying suffix .b is: 215string(7) "foo.bar" 216basename for path dir with spaces/foo.bar, supplying suffix . is: 217string(7) "foo.bar" 218basename for path dir with spaces/foo.bar, supplying suffix is: 219string(7) "foo.bar" 220basename for path dir with spaces/foo.bar, supplying suffix foo is: 221string(7) "foo.bar" 222basename for path dir with spaces/foo.bar, supplying suffix foo.bar is: 223string(7) "foo.bar" 224basename for path dir with spaces/foo.bar, supplying suffix foo/bar is: 225string(7) "foo.bar" 226basename for path dir with spaces/foo.bar, supplying suffix foo\bar is: 227string(7) "foo.bar" 228basename for path dir with spaces/foo.bar, supplying suffix / is: 229string(7) "foo.bar" 230basename for path dir with spaces/foo.bar, supplying suffix \ is: 231string(7) "foo.bar" 232basename for path dir with spaces\foo.bar, supplying suffix .bar is: 233string(19) "dir with spaces\foo" 234basename for path dir with spaces\foo.bar, supplying suffix .b is: 235string(23) "dir with spaces\foo.bar" 236basename for path dir with spaces\foo.bar, supplying suffix . is: 237string(23) "dir with spaces\foo.bar" 238basename for path dir with spaces\foo.bar, supplying suffix is: 239string(23) "dir with spaces\foo.bar" 240basename for path dir with spaces\foo.bar, supplying suffix foo is: 241string(23) "dir with spaces\foo.bar" 242basename for path dir with spaces\foo.bar, supplying suffix foo.bar is: 243string(16) "dir with spaces\" 244basename for path dir with spaces\foo.bar, supplying suffix foo/bar is: 245string(23) "dir with spaces\foo.bar" 246basename for path dir with spaces\foo.bar, supplying suffix foo\bar is: 247string(23) "dir with spaces\foo.bar" 248basename for path dir with spaces\foo.bar, supplying suffix / is: 249string(23) "dir with spaces\foo.bar" 250basename for path dir with spaces\foo.bar, supplying suffix \ is: 251string(23) "dir with spaces\foo.bar" 252 253done 254