Is it possible to use ENT_QUOTES and still use any method to break the line?
$title = htmlentities($_REQUEST['title'], ENT_QUOTES);
When i input in the field for example:
<input type="text" value="Teacher: Don't cheat at the exam<br /> 1. Rule<br /> 2. Rule<br /> 3. Rule">
And it normally must look like this:
Teacher: Don't cheat at the exam
1. Rule
2. Rule
3. Rule
But i get this:
Teacher: Don't cheat at the exam<br /> 1. Rule<br /> 2. Rule<br /> 3. Rule
Can anyone help me out?
The very essence of htmlentities()
is converting certain characters to HTML entities, and this includes <
which becomes <
and >
which becomes >
. The ENT_QUOTES
is not relevant here.
So if you are using htmlentities()
to filter your input (not sure you should, also you should probably specify $_POST
etc.), you should output it with the opposite function if you want HTML to work:
Example:
$title = htmlentities($_POST['title']);
...
echo html_entity_decode($title); // outputs proper HTML
But devoid of more context, this example is meaningless and there is almost certainly a better way to do this in your project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.