Different result of XML parser in different environment, WHY?
<?php
$xml = <<< AAA
<test>c đưa lên 1 -> 10 k</test>
AAA;
$p = xml_parser_create();
xml_parse_into_struct($p, $xml, $vals, $index);
xml_parser_free($p);
print_r($vals);
I can get differnt result why? In my PC the result is
Array
(
[0] => Array
(
[tag] => 开发者_如何学运维TEST
[type] => complete
[level] => 1
[value] => c đưa lên 1 -> 10 k
)
)
In the procuction environment, the resut is
Array
(
[0] => Array
(
[tag] => TEST
[type] => complete
[level] => 1
[value] => c đưa lên 1 - 10 k
)
)
The > is disappear. Why?
Sometimes, when you switch environments, you will see some differences related to text encoding and other internationlization-related gotchas. So you can try explicitly setting an encoding in the xml_parser_create function.
Another thing to consider is PHP versions. Run a phpinfo()
from both environments and check the versions there. It may be that the PHP version production is using is coded to ignore HTML entities (>) ... just a guess.
EDIT:
According to this bug report, this behavior of ignoring HTML entities can be cause by libxml2. Try updating libxml2 on the production server to the latest version.
Seems to be an encoding problem.
精彩评论