I am trying to output code into an input value like the below:
echo '<input value="'.$row['content'].'"></input>';
$row['content'] would include simple html, a full page code for example. With the current setup however it is breaking out of the input field and pouring into the page code.
I would like a way for it to show all HTML as text including all tags and to stay confined within the input field itself.
Thanks.
CodePudding user response:
Try this
echo '<textarea>'.$row['content'].'</textarea>';
CodePudding user response:
if I undersand it correctly
<?php echo strip_tags($row['content']) ?>
CodePudding user response:
You could make use of htmlentities() function
<input value="<?= htmlentities($row['content']; ?>">
CodePudding user response:
Use the function htmlspecialchars_decode
by doing:
echo '<input value="'.htmlspecialchars_decode($row['content']).'">' ;