DanielHardy Posted March 8, 2009 Share Posted March 8, 2009 I am applying this to a string as follows: <?php echo $this->escape( nl2br($forum->comment));?> However when i go the page to view the result it doesnt display the breaks, but the code to create them. I.e My starting XI of all time would be:<br /> <br /> Goalkeeper: Peter Schmeicel<br /> Any ideas why? I've looked for help on many a website but can't find a solution for what I deem to be a simple problem. Thanks in advance Daniel Quote Link to comment https://forums.phpfreaks.com/topic/148492-solved-nl2br-problems/ Share on other sites More sharing options...
premiso Posted March 8, 2009 Share Posted March 8, 2009 What does the escape function do? If it uses htmlentities or strip_tags then that is your problem. But if this is for inserting it into the DB I would not do nl2br before putting the data into the DB. Instead do it when retrieving the data. You want to store the data in it's raw format. Quote Link to comment https://forums.phpfreaks.com/topic/148492-solved-nl2br-problems/#findComment-779762 Share on other sites More sharing options...
DanielHardy Posted March 8, 2009 Author Share Posted March 8, 2009 Yeah it uses strip_tags() Is there another way of achieving the line breaks then? Quote Link to comment https://forums.phpfreaks.com/topic/148492-solved-nl2br-problems/#findComment-779767 Share on other sites More sharing options...
premiso Posted March 8, 2009 Share Posted March 8, 2009 <?php echo nl2br($this->escape( $forum->comment));?> Quote Link to comment https://forums.phpfreaks.com/topic/148492-solved-nl2br-problems/#findComment-779773 Share on other sites More sharing options...
DanielHardy Posted March 8, 2009 Author Share Posted March 8, 2009 Seems very simple now! Working like a dream. Thanks a lot Dan Quote Link to comment https://forums.phpfreaks.com/topic/148492-solved-nl2br-problems/#findComment-779781 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.