1--TEST--
2Test strrchr() function : usage variations - heredoc string containing special chars 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 special chars for haystack
11 * and with various needles
12*/
13
14echo "*** Testing strrchr() function: with heredoc strings ***\n";
15$special_chars_str = <<<EOD
16Example of heredoc string contains
17$#%^*&*_("_")!#@@!$#$^^&*(special)
18chars.
19EOD;
20
21$heredoc_needle = <<<EOD
22^^&*(
23EOD;
24
25$needles = array(
26  "!@@!",
27  '_',
28  '("_")',
29  "$*",
30  "(special)",
31  $heredoc_needle,  //needle as heredoc string
32  $special_chars_str  //needle as haystack
33);
34
35//loop through to test strrchr() with each needle
36foreach($needles as $needle) {
37  var_dump( strrchr($special_chars_str, $needle) );
38}
39echo "*** Done ***";
40?>
41--EXPECTF--
42*** Testing strrchr() function: with heredoc strings ***
43string(24) "!$#$^^&*(special)
44chars."
45string(31) "_")!#@@!$#$^^&*(special)
46chars."
47string(16) "(special)
48chars."
49string(21) "$^^&*(special)
50chars."
51string(16) "(special)
52chars."
53string(19) "^&*(special)
54chars."
55string(76) "Example of heredoc string contains
56$#%^*&*_("_")!#@@!$#$^^&*(special)
57chars."
58*** Done ***
59