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