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 empty string
22  var_dump( strrchr($haystacks[$index], "") );
23}
24echo "*** Done ***";
25?>
26--EXPECTF--
27*** Test strrchr() function: binary safe ***
28string(6) "%0World"
29string(6) "%0World"
30string(12) "%0Hello World"
31string(12) "%0Hello World"
32string(1) "%0"
33string(1) "%0"
34string(1) "%0"
35string(1) "%0"
36string(6) "%0world"
37string(6) "%0world"
38string(6) "%0Hello"
39string(6) "%0Hello"
40string(1) "%0"
41string(1) "%0"
42*** Done ***
43