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