Why does the example from the PHP manual output a blank string when using htmlentities, but the input string is displayed as is when passed through GET?

The issue occurs because when using htmlentities, the input string is encoded to HTML entities, which may include characters like < and >. When this encoded string is passed through GET, the browser interprets these characters as part of the URL and does not display them as intended. To solve this, you can use urldecode() to decode the string before displaying it.

$input = $_GET[&#039;input&#039;]; // Assuming the input is passed through GET
$decoded_input = urldecode($input);
echo htmlentities($decoded_input);