There is a problem with output in yii. CHtml :: encode ($ text) displays everything in one line. If you apply nl2br and output simply: echo nl2br ($ text), then everything is OK. But then the user will be able to enter tags. If CHtml :: encode (nl2br ($ text)) - it is logical that it will output in one line, but with tags.

How to solve the problem without too much parsing?

  • CHtml :: encode (nl2br ($ text)) is not logical, for CHtml :: encode () is a replacement for htmlspecialchars () that cuts tags) - tranceman
  • Well, I meant that it will display text with tags in the text itself, and not in html - Ray

1 answer 1

Something completely stupid at night ...

echo nl2br( CHtml::encode($text) ); 

And everything is OK))