I was just trying to figure out how the htmlentities function works. My initial goal (just for practice) was to make a form that would encode / decode code to and from html entities. First I am trying to get the form to encode to entities. Once I understand how that works i’ll try to decode entities back to text. I thought I had it figured out but somethings wrong its not printing out. Any troubleshooting help would be appreciated.
<!DOCTYPE html>
<html>
<head>
<title>Practice</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" >
<p>Code:</p>
<textarea name="codeArea" rows="4" cols="50"></textarea>
<input type="submit" value="hit it!">
</form>
<?php
$text = $_POST['codeArea'];
$UserInputText = htmlentities($text);
echo '<code>'.$UserInputText.'</code>';
?>
</body>
</html>