summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/nl2br_variation3.phpt
blob: 587518d1eee72ffb958687b20501ea1e0e5fb229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--TEST--
Test nl2br() function : usage variations - heredoc strings for 'str' argument
--FILE--
<?php
/* Prototype  : string nl2br(string $str);
 * Description: Inserts HTML line breaks before all newlines in a string.
 * Source code: ext/standard/string.c
*/

/* Test nl2br() function by passing heredoc strings containing various
 *   combinations of new line chars to 'str' argument
*/

echo "*** Testing nl2br() : usage variations ***\n";
//heredoc string containing new line chars(\n, \r and combinations of \r & \n) and new lines
$heredoc_str1 = <<<EOD
\n
\r
\r\n
\nnn\n\n\nn
\rrr\r\r\rr
\n\r\n\r\r\n\nr\rn
EOD;

//heredoc string containing embedded 'new line chars'/'new lines' in the string
$heredoc_str2 = <<<EOD
Hello\nWorld\r
This is \tes\t for \n \new lines
like \n \r\n \r \n\r and etc
EOD;

var_dump(nl2br($heredoc_str1) );
var_dump(nl2br($heredoc_str2) );

echo "Done";
?>
--EXPECT--
*** Testing nl2br() : usage variations ***
string(147) "<br />
<br />

<br />

<br />
<br />
<br />
nn<br />
<br />
<br />
n<br />

rr<br />
<br />
<br />
r<br />
<br />

<br />

<br />
<br />
r<br />
n"
string(118) "Hello<br />
World<br />
This is 	es	 for <br />
 <br />
ew lines<br />
like <br />
 <br />
 <br />
 <br />

 and etc"
Done