1--TEST--
2Test strrchr() function : usage variations - binary safe
3--FILE--
4<?php
5/* Test strrchr() function: with binary values & null terminated strings passed to 'str1' & 'str2' */
6
7echo "*** Test strrchr() function: binary safe ***\n";
8$haystacks = array(
9  "Hello".chr(0)."World",
10  chr(0)."Hello World",
11  "Hello World".chr(0),
12  chr(0).chr(0).chr(0),
13  "Hello\0world",
14  "\0Hello",
15  "Hello\0"
16);
17
18for($index = 0; $index < count($haystacks); $index++ ) {
19  //needle as null string
20  var_dump( strrchr($haystacks[$index], "\0") );
21  //needle as NULL
22  var_dump( strrchr($haystacks[$index], NULL) );
23}
24echo "*** Done ***";
25?>
26--EXPECT--
27*** Test strrchr() function: binary safe ***
28string(6) "�World"
29string(6) "�World"
30string(12) "�Hello World"
31string(12) "�Hello World"
32string(1) "�"
33string(1) "�"
34string(1) "�"
35string(1) "�"
36string(6) "�world"
37string(6) "�world"
38string(6) "�Hello"
39string(6) "�Hello"
40string(1) "�"
41string(1) "�"
42*** Done ***
43