1--TEST-- 2Test strrchr() function : usage variations - single quoted strings 3--FILE-- 4<?php 5/* Test strrchr() function by passing various single quoted strings to 'haystack' & 'needle' */ 6 7echo "*** Testing strrchr() function: with various single quoted strings ***"; 8$haystack = 'Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 '; 9$needle = array( 10 //regular strings 11 'l', 12 'L', 13 'HELLO', 14 'hEllo', 15 16 //escape characters 17 '\t', 18 '\T', 19 ' ', 20 '\n', 21 '\N', 22 ' 23', //new line 24 25 //nulls 26 '\0', 27 NULL, 28 null, 29 30 //boolean false 31 FALSE, 32 false, 33 34 //empty string 35 '', 36 37 //special chars 38 ' ', 39 '$', 40 ' $', 41 '&', 42 '!#', 43 '%\o', 44 '\o,', 45 '()', 46 '*+', 47 '+', 48 '-', 49 '.', 50 '.;', 51 ':;', 52 ';', 53 '<=>', 54 '>', 55 '=>', 56 '?', 57 '@', 58 '@hEllo', 59 60 '12345', //decimal numeric string 61 '\x23', //hexadecimal numeric string 62 '#', //hexadecimal numeric string 63 '\101', //octal numeric string 64 'A', 65 '456HEE', //numerics + chars 66 42, //needle as int(ASCII value of '*') 67 $haystack //haystack as needle 68); 69 70/* loop through to get the position of the needle in haystack string */ 71$count = 1; 72for($index=0; $index<count($needle); $index++) { 73 echo "\n-- Iteration $count --\n"; 74 var_dump( strrchr($haystack, $needle[$index]) ); 75 $count ++; 76} 77echo "*** Done ***"; 78?> 79--EXPECT-- 80*** Testing strrchr() function: with various single quoted strings *** 81-- Iteration 1 -- 82string(22) "lo123456he \x234 \101 " 83 84-- Iteration 2 -- 85bool(false) 86 87-- Iteration 3 -- 88string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 89 90-- Iteration 4 -- 91string(14) "he \x234 \101 " 92 93-- Iteration 5 -- 94string(5) "\101 " 95 96-- Iteration 6 -- 97string(5) "\101 " 98 99-- Iteration 7 -- 100string(1) " " 101 102-- Iteration 8 -- 103string(5) "\101 " 104 105-- Iteration 9 -- 106string(5) "\101 " 107 108-- Iteration 10 -- 109bool(false) 110 111-- Iteration 11 -- 112string(5) "\101 " 113 114-- Iteration 12 -- 115bool(false) 116 117-- Iteration 13 -- 118bool(false) 119 120-- Iteration 14 -- 121bool(false) 122 123-- Iteration 15 -- 124bool(false) 125 126-- Iteration 16 -- 127bool(false) 128 129-- Iteration 17 -- 130string(1) " " 131 132-- Iteration 18 -- 133string(47) "$&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 134 135-- Iteration 19 -- 136string(1) " " 137 138-- Iteration 20 -- 139string(46) "&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 140 141-- Iteration 21 -- 142string(45) "!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 143 144-- Iteration 22 -- 145string(43) "%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 146 147-- Iteration 23 -- 148string(5) "\101 " 149 150-- Iteration 24 -- 151string(39) "()*+-./:;<=>?@hello123456he \x234 \101 " 152 153-- Iteration 25 -- 154string(37) "*+-./:;<=>?@hello123456he \x234 \101 " 155 156-- Iteration 26 -- 157string(36) "+-./:;<=>?@hello123456he \x234 \101 " 158 159-- Iteration 27 -- 160string(35) "-./:;<=>?@hello123456he \x234 \101 " 161 162-- Iteration 28 -- 163string(34) "./:;<=>?@hello123456he \x234 \101 " 164 165-- Iteration 29 -- 166string(34) "./:;<=>?@hello123456he \x234 \101 " 167 168-- Iteration 30 -- 169string(32) ":;<=>?@hello123456he \x234 \101 " 170 171-- Iteration 31 -- 172string(31) ";<=>?@hello123456he \x234 \101 " 173 174-- Iteration 32 -- 175string(30) "<=>?@hello123456he \x234 \101 " 176 177-- Iteration 33 -- 178string(28) ">?@hello123456he \x234 \101 " 179 180-- Iteration 34 -- 181string(29) "=>?@hello123456he \x234 \101 " 182 183-- Iteration 35 -- 184string(27) "?@hello123456he \x234 \101 " 185 186-- Iteration 36 -- 187string(26) "@hello123456he \x234 \101 " 188 189-- Iteration 37 -- 190string(26) "@hello123456he \x234 \101 " 191 192-- Iteration 38 -- 193string(2) "1 " 194 195-- Iteration 39 -- 196string(5) "\101 " 197 198-- Iteration 40 -- 199string(44) "#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 200 201-- Iteration 41 -- 202string(5) "\101 " 203 204-- Iteration 42 -- 205bool(false) 206 207-- Iteration 43 -- 208string(7) "4 \101 " 209 210-- Iteration 44 -- 211string(7) "4 \101 " 212 213-- Iteration 45 -- 214string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 " 215*** Done *** 216