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