Reputation: 962
I have the following piece of code.
<?php
$agentId = "LTH001";
echo "&&" . $agentId;
?>
The output is &<H001
whereas I expected &<H001
. I guess there is a conversion issue causing this output. Why do I get the unexpected output?
Upvotes: 2
Views: 108
Reputation: 5115
You should use http://www.php.net/htmlspecialchars in order to avoid HTML converting of undesired strings:
echo htmlspecialchars("&&".$agentId);
Upvotes: 2
Reputation: 324650
Your output is: &<H001
.
Your browser is seeing the <
and interpreting it as a character code (albeit a malformed one), and replacing it with <
.
Please View Source or use htmlspecialchars
next time ;)
Upvotes: 6