1--TEST--
2Test strrpos() function : usage variations - checking binary safe with 'haystack' 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 'haystack' argument
11 *  in order to check the binary safe
12*/
13
14echo "*** Test strrpos() 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
25for($index = 0; $index < count($haystacks); $index++ ) {
26  var_dump( strrpos($haystacks[$index], "\0") );
27  var_dump( strrpos($haystacks[$index], "\0", $index) );
28}
29echo "*** Done ***";
30?>
31--EXPECT--
32*** Test strrpos() function: binary safe ***
33int(5)
34int(5)
35int(0)
36bool(false)
37int(11)
38int(11)
39int(2)
40bool(false)
41int(5)
42int(5)
43int(0)
44bool(false)
45int(5)
46bool(false)
47*** Done ***
48