Annotation of embedaddon/php/ext/standard/tests/strings/strrpos_variation13.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strrpos() function : usage variations - checking bianry safe with 'needle' argument
3: --FILE--
4: <?php
5: /* Prototype : int strrpos ( string $haystack, string $needle [, int $offset] );
6: * Description: Find position of last occurrence of 'needle' in 'haystack'.
7: * Source code: ext/standard/string.c
8: */
9:
10: /* Test strrpos() function with null terminated strings for 'needle' argument
11: * in order to check binary safe
12: */
13:
14: echo "*** Test strrpos() function: binary safe ***\n";
15: $haystack = "\0Hello\0World\0";
16:
17: $needles = array(
18: "Hello".chr(0)."World",
19: chr(0)."Hello\0",
20: chr(0),
21: "Hello\0world",
22: "\0Hello\0world\0",
23: "\0Hello",
24: "Hello\0"
25: );
26:
27: for($index = 0; $index < count($needles); $index++ ) {
28: var_dump( strrpos($haystack, $needles[$index]) );
29: var_dump( strrpos($haystack, $needles[$index], $index) );
30: }
31: echo "*** Done ***";
32: ?>
33: --EXPECTF--
34: *** Test strrpos() function: binary safe ***
35: int(1)
36: int(1)
37: int(0)
38: bool(false)
39: int(12)
40: int(12)
41: bool(false)
42: bool(false)
43: bool(false)
44: bool(false)
45: int(0)
46: bool(false)
47: int(1)
48: bool(false)
49: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>