1--TEST--
2Test 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
14echo "*** 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
27for($index = 0; $index < count($needles); $index++ ) {
28  var_dump( strrpos($haystack, $needles[$index]) );
29  var_dump( strrpos($haystack, $needles[$index], $index) );
30}
31echo "*** Done ***";
32?>
33--EXPECT--
34*** Test strrpos() function: binary safe ***
35int(1)
36int(1)
37int(0)
38bool(false)
39int(12)
40int(12)
41bool(false)
42bool(false)
43bool(false)
44bool(false)
45int(0)
46bool(false)
47int(1)
48bool(false)
49*** Done ***
50