tags:

views:

51

answers:

2
<?php
$xml = <<< AAA
<test>c đưa lên 1 -&gt; 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?

A: 

Seems to be an encoding problem.

powtac
which is your result?
bruce dou
+3  A: 

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 (&gt;) ... 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.

Matt
Can not see any difference of phpinfo. The encoding of both are utf8.
bruce dou
And < not disappear.
bruce dou
Check the bug report in my edit. If the php versions are the same, then the libxml2 difference would make sense.
Matt
Both of the libxml2 Version is 2.6.32
bruce dou