1--TEST--
2Test nl2br() function : usage variations - heredoc strings for 'str' argument
3--FILE--
4<?php
5/* Prototype  : string nl2br(string $str);
6 * Description: Inserts HTML line breaks before all newlines in a string.
7 * Source code: ext/standard/string.c
8*/
9
10/* Test nl2br() function by passing heredoc strings containing various
11 *   combinations of new line chars to 'str' argument
12*/
13
14echo "*** Testing nl2br() : usage variations ***\n";
15//heredoc string containing new line chars(\n, \r and combinations of \r & \n) and new lines
16$heredoc_str1 = <<<EOD
17\n
18\r
19\r\n
20\nnn\n\n\nn
21\rrr\r\r\rr
22\n\r\n\r\r\n\nr\rn
23EOD;
24
25//heredoc string containing embedded 'new line chars'/'new lines' in the string
26$heredoc_str2 = <<<EOD
27Hello\nWorld\r
28This is \tes\t for \n \new lines
29like \n \r\n \r \n\r and etc
30EOD;
31
32var_dump(nl2br($heredoc_str1) );
33var_dump(nl2br($heredoc_str2) );
34
35echo "Done";
36?>
37--EXPECTF--
38*** Testing nl2br() : usage variations ***
39string(147) "<br />
40<br />
41
41<br />
42
42<br />
43<br />
44<br />
45nn<br />
46<br />
47<br />
48n<br />
49
49rr<br />
49<br />
49<br />
49r<br />
50<br />
51
51<br />
52
52<br />
53<br />
54r<br />
54n"
55string(118) "Hello<br />
56World<br />
57This is 	es	 for <br />
58 <br />
59ew lines<br />
60like <br />
61 <br />
62 <br />
62 <br />
63
63 and etc"
64Done
65