Annotation of embedaddon/php/ext/standard/tests/strings/nl2br_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test nl2br() function : usage variations - double quoted 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 double quoted strings containing various
11: * combinations of new line chars to 'str' argument
12: */
13:
14: echo "*** Testing nl2br() : usage variations ***\n";
15:
16: $strings = array(
17: //new line chars embedded in strings
18: "Hello\nWorld",
19: "\nHello\nWorld\n",
20: "Hello\rWorld",
21: "\rHello\rWorld\r",
22: "Hello\r\nWorld",
23: "\r\nHello\r\nWorld\r\n",
24:
25: //one blank line
26: "
27: ",
28:
29: //two blank lines
30: "
31:
32: ",
33:
34: //inserted new line in a string
35: "Hello
36: World"
37: );
38:
39: //loop through $strings array to test nl2br() function with each element
40: $count = 1;
41: foreach( $strings as $str ){
42: echo "-- Iteration $count --\n";
43: var_dump(nl2br($str) );
44: $count ++ ;
45: }
46: echo "Done";
47: ?>
48: --EXPECTF--
49: *** Testing nl2br() : usage variations ***
50: -- Iteration 1 --
51: string(17) "Hello<br />
52: World"
53: -- Iteration 2 --
54: string(31) "<br />
55: Hello<br />
56: World<br />
57: "
58: -- Iteration 3 --
59: string(17) "Hello<br />
World"
60: -- Iteration 4 --
61: string(31) "<br />
Hello<br />
World<br />
"
62: -- Iteration 5 --
63: string(18) "Hello<br />
64: World"
65: -- Iteration 6 --
66: string(34) "<br />
67: Hello<br />
68: World<br />
69: "
70: -- Iteration 7 --
71: string(7) "<br />
72: "
73: -- Iteration 8 --
74: string(14) "<br />
75: <br />
76: "
77: -- Iteration 9 --
78: string(17) "Hello<br />
79: World"
80: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>