How do I output a formatted text using php. I’m storing it in a field will longtext data type. I save the data using the code below:
<?php
if(!empty($_POST)){
$code = mysql_real_escape_string($_POST['x']);
$db->query("INSERT INTO tbl_codes SET code='$code'");
}
?>
But when I try to retrieve it:
<?php echo htmlentities($yo); ?>
It’s not already formatted. And if I don’t use the htmlentities function, I don’t see any output. Please help
As the doc says,
htmlentitieswill convert chars like ‘<‘ and ‘>‘ in ‘<‘ and ‘>‘ thus the html tags will have no effect. For example, if you have bolded text like this:it will be converted in:
Since in your last comment you write that you only need the
<pre>tag, you can consider the possibility to use strip_tags like: