开发者

PHP automaticly parses my string?

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开发者_JS百科 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜