I am passing a string with $_GET and attempting to print it with echo. The issue is the content in the $_GET contains an & and when I echo the string it doesnt print the & or anything after it. For example,
I have tried just echoing the $_GET['subject']. I have also tried running it through htmlspecialchars(). I have also tried replacing the & with regrex but nothing seems to work.
Whenever I print out the variable it is turned from "Kim & Kanye! Will it last?" into "Kim"
Either use htmlspecialchars() or htmlentities() on the text being output.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
We may need to see a bit of the actual PHP code to better understand what you are trying to do. Maybe it's just a case of a HTML tag attribute's value not being quoted?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Figured it out. Just needed to add urlencode() to the variable before it was passed via $_GET. That allows the & to get passed and then I used htmlentitites() on the receiving end before echoing.
Bookmarks