Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Test nl2br() function : usage variations - single quoted strings for 'str' argume..

Decoded Output download

*** Testing nl2br() : usage variations ***
-- Iteration 1 --

Did this file decode correctly?

Original Code

--TEST--
Test nl2br() function : usage variations - single quoted strings for 'str' argument
--FILE--
<?php
/* Test nl2br() function by passing single quoted strings containing various
 *   combinations of new line chars to 'str' argument
*/

echo "*** Testing nl2br() : usage variations ***\n";
$strings = array(
  '\n',
  '\r',
  '\r\n',
  'Hello\nWorld',
  'Hello\rWorld',
  'Hello\r\nWorld',

  //one blank line
  '
',

  //two blank lines
  '

',

  //inserted new line
  'Hello
World'
);

//loop through $strings array to test nl2br() function with each element
$count = 1;
foreach( $strings as $str ){
  echo "-- Iteration $count --\n";
  var_dump(nl2br($str) );
  $count ++ ;
}
echo "Done";
?>
--EXPECT--
*** Testing nl2br() : usage variations ***
-- Iteration 1 --
string(2) "\n"
-- Iteration 2 --
string(2) "\r"
-- Iteration 3 --
string(4) "\r\n"
-- Iteration 4 --
string(12) "Hello\nWorld"
-- Iteration 5 --
string(12) "Hello\rWorld"
-- Iteration 6 --
string(14) "Hello\r\nWorld"
-- Iteration 7 --
string(7) "<br />
"
-- Iteration 8 --
string(14) "<br />
<br />
"
-- Iteration 9 --
string(17) "Hello<br />
World"
Done

Function Calls

nl2br 1

Variables

$str \n
$count 1
$strings [{'key': 0, 'value': '\\n'}, {'key': 1, 'value': '\\r'}, {'key': 2, 'value': '\\r\\n'}, {'key': 3, 'value': 'Hello\\nWorld'}, {'key': 4, 'value': 'Hello\\rWorld'}, {'key': 5, 'value': 'Hello\\r\\nWorld'}, {'key': 6, 'value': '\n'}, {'key': 7, 'value': '\n\n'}, {'key': 8, 'value': 'Hello\nWorld'}]

Stats

MD5 1f02f7964a815454eed6becae0d6cf7c
Eval Count 0
Decode Time 101 ms