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