1--TEST--
2Test strrev() function : usage variations - heredoc strings
3--FILE--
4<?php
5/* Prototype  : string strrev(string $str);
6 * Description: Reverse a string
7 * Source code: ext/standard/string.c
8*/
9
10/* Testing strrev() function with heredoc strings for 'str' */
11
12echo "*** Testing strrev() function: with heredoc strings ***\n";
13$multi_line_str = <<<EOD
14Example of string
15spanning multiple lines
16using heredoc syntax.
17EOD;
18
19$special_chars_str = <<<EOD
20Ex'ple of h'doc st'g, contains
21$#%^*&*_("_")!#@@!$#$^^&*(special)
22chars.
23EOD;
24
25$control_chars_str = <<<EOD
26Hello, World\n
27Hello\0World
28EOD;
29
30$quote_chars_str = <<<EOD
31it's bright o'side
32"things in double quote"
33'things in single quote'
34this\line is /with\slashs
35EOD;
36
37$blank_line = <<<EOD
38
39EOD;
40
41$empty_str = <<<EOD
42EOD;
43
44$strings = array(
45  $multi_line_str,
46  $special_chars_str,
47  $control_chars_str,
48  $quote_chars_str,
49  $blank_line,
50  $empty_str
51);
52
53$count = 1;
54for( $index = 0; $index < count($strings); $index++ ) {
55  echo "\n-- Iteration $count --\n";
56  var_dump( strrev($strings[$index]) );
57  $count ++;
58}
59
60echo "*** Done ***";
61?>
62--EXPECT--
63*** Testing strrev() function: with heredoc strings ***
64
65-- Iteration 1 --
66string(63) ".xatnys codereh gnisu
67senil elpitlum gninnaps
68gnirts fo elpmaxE"
69
70-- Iteration 2 --
71string(72) ".srahc
72)laiceps(*&^^$#$!@@#!)"_"(_*&*^%#$
73sniatnoc ,g'ts cod'h fo elp'xE"
74
75-- Iteration 3 --
76string(25) "dlroW�olleH
77
78dlroW ,olleH"
79
80-- Iteration 4 --
81string(94) "shsals\htiw/ si enil\siht
82'etouq elgnis ni sgniht'
83"etouq elbuod ni sgniht"
84edis'o thgirb s'ti"
85
86-- Iteration 5 --
87string(0) ""
88
89-- Iteration 6 --
90string(0) ""
91*** Done ***
92