tags:

views:

31

answers:

1

Some Background info: My web application stores some XML in a Text column of the MySQL database. This XML represents a transaction for the application.


The problem occurs when I'm testing my library. Within PHP, I have a string:

$s="<flist><transaction amount=\"10\" type=\"income\">Initial Amount</transaction></flist>";

However, whenever I echo or consecrate this string, it turns into "Initial Amount". Am I missing a feature of PHP? How can I fix this? Wow! As I'm creating this post, StackOverflow is transforming that XML into $s=Initial Amount as well... Please help... Thank-you for your time as this completely perplexes me.

+3  A: 

PHP doesn't automatically parse the string.

Are you echoing it and viewing it in a browser? It's very likely that the browser skips over the unknown tags and shows what it can. You might want to considering adding in htmlspecialchars() to your output like so:

echo htmlspecialchars($s);

You should also see it correctly when viewing the web source. This is a feature of HTML to support future versions without breaking current ones.

AlReece45
Wow; that was it. I feel dumb... I thought surrounding it with pre tags would stop that. That was the problem. Thank-you!
PlagueEditor