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