I have this line of code:
$content = strip_tags($content, '<a><br><b><i>');
It works like it should, but I need for users to be able to enter code and for the code to be displayed on the web-page.
For example,
<?php
echo 'Hey';
?>
displays nothing. I need it to display
<?php
echo 'Hey';
?>
for example. What function should I use to do this?
EDIT: To clarify, the user sees the PHP code, it just gets replaced with HTML entities so the server doesn't try to run it.
Try:
$content = htmlspecialchars(strip_tags($content, '<a><br><b><i>'));
Or
$content = htmlentities(strip_tags($content, '<a><br><b><i>'), ENT_QUOTES);
See htmlspecialchars
and htmlentities
.
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.