Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / strings / nl2br_variation1.phpt
blobab15ca1fe4be989e9512f42d6f21e791fced5b5f
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 */
10 /* Test nl2br() function by passing double quoted strings containing various 
11  *   combinations of new line chars to 'str' argument
14 echo "*** Testing nl2br() : usage variations ***\n";
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",
25   //one blank line 
26   "
29   //two blank lines
30   "
34   //inserted new line in a string
35   "Hello
36 World"
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 ++ ;
46 echo "Done";
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 />
58 -- Iteration 3 --
59 string(17) "Hello<br />\rWorld"
60 -- Iteration 4 --
61 string(31) "<br />\rHello<br />\rWorld<br />\r"
62 -- Iteration 5 --
63 string(18) "Hello<br />
64 World"
65 -- Iteration 6 --
66 string(34) "<br />
67 Hello<br />
68 World<br />
70 -- Iteration 7 --
71 string(7) "<br />
73 -- Iteration 8 --
74 string(14) "<br />
75 <br />
77 -- Iteration 9 --
78 string(17) "Hello<br />
79 World"
80 Done