Return to stripos_variation12.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test stripos() function : usage variations - null terminated strings for 'haystack' argument 3: --FILE-- 4: <?php 5: /* Prototype : int stripos ( string $haystack, string $needle [, int $offset] ); 6: * Description: Find position of first occurrence of a case-insensitive string 7: * Source code: ext/standard/string.c 8: */ 9: 10: /* Test stripos() function with null terminated strings for 'haystack' argument 11: * in order to check the binary safe 12: */ 13: 14: echo "*** Test stripos() function: binary safe ***\n"; 15: $haystacks = array( 16: "Hello".chr(0)."World", 17: chr(0)."Hello World", 18: "Hello World".chr(0), 19: chr(0).chr(0).chr(0), 20: "Hello\0world", 21: "\0Hello", 22: "Hello\0" 23: ); 24: 25: for($index = 0; $index < count($haystacks); $index++ ) { 26: var_dump( stripos($haystacks[$index], "\0") ); 27: var_dump( stripos($haystacks[$index], "\0", $index) ); 28: } 29: echo "*** Done ***"; 30: ?> 31: --EXPECTF-- 32: *** Test stripos() function: binary safe *** 33: int(5) 34: int(5) 35: int(0) 36: bool(false) 37: int(11) 38: int(11) 39: int(0) 40: bool(false) 41: int(5) 42: int(5) 43: int(0) 44: bool(false) 45: int(5) 46: bool(false) 47: *** Done ***