Reputation: 1303
In my MySQL database I have someting like "Hello <<smt>>"
and I use PHP to echo this out nl2br($msg['CONTENT']);
The output in index.php
is:
"Hello <>"
Why's that?
And if I have in database something like "Hello <smt>"
in index.php
show me only "Hello"
. What to do?
Upvotes: 1
Views: 108
Reputation: 5094
nl2br
only turns \n
into <br/>
.
string nl2br ( string $string [, bool $is_xhtml = true ] )
Returns string with
<br />
or<br>
inserted before all newlines (\r\n, \n\r, \n and \r).
It has nothing to do with your problem. Your problem has to do with trying to display HTML tags. The browser recognize those tags and tries to parse them (like if it were a <span>
).
To use those tags as display characters, just use htmlentities
.
Example
htmlentities(nl2br($msg['CONTENT']));
Upvotes: 2