1--TEST--
2Test strrchr() function : usage variations - heredoc string containing escape sequences for 'haystack'
3--FILE--
4<?php
5/* Prototype  : string strrchr(string $haystack, string $needle);
6 * Description: Finds the last occurrence of a character in a string.
7 * Source code: ext/standard/string.c
8*/
9
10/* Test strrchr() function by passing heredoc string containing
11 *  escape sequences for haystack and with various needles
12*/
13
14echo "*** Testing strrchr() function: with heredoc strings ***\n";
15$escape_char_str = <<<EOD
16\tes\t st\r\rch\r using
17\escape \\seque\nce
18EOD;
19
20$needles = array(
21  "\t",
22  '\n',
23  "\r",
24  "\\",
25  $escape_char_str //needle as haystack
26);
27
28//loop through to test strrchr() with each needle
29foreach($needles as $needle) {
30  var_dump( strrchr($escape_char_str, $needle) );
31}
32
33echo "*** Done ***";
34?>
35--EXPECTF--
36*** Testing strrchr() function: with heredoc strings ***
37string(32) "	 st
37
37ch
37 using
38scape \seque
39ce"
40string(9) "\seque
41ce"
42string(24) "
42 using
43scape \seque
44ce"
45string(9) "\seque
46ce"
47string(32) "	 st
47
47ch
47 using
48scape \seque
49ce"
50*** Done ***
51