Annotation of embedaddon/php/ext/standard/tests/strings/strrchr_variation4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
14: echo "*** Testing strrchr() function: with heredoc strings ***\n";
15: $special_chars_str = <<<EOD
16: Example of heredoc string contains
17: $#%^*&*_("_")!#@@!$#$^^&*(special)
18: chars.
19: EOD;
20:
21: $heredoc_needle = <<<EOD
22: ^^&*(
23: EOD;
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
36: foreach($needles as $needle) {
37: var_dump( strrchr($special_chars_str, $needle) );
38: }
39: echo "*** Done ***";
40: ?>
41: --EXPECTF--
42: *** Testing strrchr() function: with heredoc strings ***
43: string(24) "!$#$^^&*(special)
44: chars."
45: string(31) "_")!#@@!$#$^^&*(special)
46: chars."
47: string(16) "(special)
48: chars."
49: string(21) "$^^&*(special)
50: chars."
51: string(16) "(special)
52: chars."
53: string(19) "^&*(special)
54: chars."
55: string(76) "Example of heredoc string contains
56: $#%^*&*_("_")!#@@!$#$^^&*(special)
57: chars."
58: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>