Jump to content

Avoid sql injection but still have break lines


aliento

Recommended Posts

When outputting the data, use nl2br to convert line ending characters to new lines.

 

Take this for example:

 

<?PHP

  $string = "This is a string. \r\n This is on a new line.";
 
  echo 'Without nl2br() <br> "'. $string.'"';
 
  echo '<br>---------------------------<br>';
 
  echo 'With nl2br() <br> "'. nl2br($string) .'"';

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.