1--TEST-- 2Test nl2br() function : usage variations - single quoted strings for 'str' argument 3--FILE-- 4<?php 5/* Test nl2br() function by passing single quoted strings containing various 6 * combinations of new line chars to 'str' argument 7*/ 8 9echo "*** Testing nl2br() : usage variations ***\n"; 10$strings = array( 11 '\n', 12 '\r', 13 '\r\n', 14 'Hello\nWorld', 15 'Hello\rWorld', 16 'Hello\r\nWorld', 17 18 //one blank line 19 ' 20', 21 22 //two blank lines 23 ' 24 25', 26 27 //inserted new line 28 'Hello 29World' 30); 31 32//loop through $strings array to test nl2br() function with each element 33$count = 1; 34foreach( $strings as $str ){ 35 echo "-- Iteration $count --\n"; 36 var_dump(nl2br($str) ); 37 $count ++ ; 38} 39echo "Done"; 40?> 41--EXPECT-- 42*** Testing nl2br() : usage variations *** 43-- Iteration 1 -- 44string(2) "\n" 45-- Iteration 2 -- 46string(2) "\r" 47-- Iteration 3 -- 48string(4) "\r\n" 49-- Iteration 4 -- 50string(12) "Hello\nWorld" 51-- Iteration 5 -- 52string(12) "Hello\rWorld" 53-- Iteration 6 -- 54string(14) "Hello\r\nWorld" 55-- Iteration 7 -- 56string(7) "<br /> 57" 58-- Iteration 8 -- 59string(14) "<br /> 60<br /> 61" 62-- Iteration 9 -- 63string(17) "Hello<br /> 64World" 65Done 66