user1345414
user1345414

Reputation: 3865

Difference behavior of PHP to show xml

This is my php code.

[xmltest.php]

<?xml version="1.0" encoding="UTF-8"?>
<results>
  <date>test data</date>
</results>

When I run it in tow servers each results are different.

Results in browser from server1 and server2 are here.

[server1]

<?xml version="1.0" encoding="UTF-8"?>
-<results>
<date>test data</date>
 </results>

[server2]

Parse error: syntax error, unexpected T_STRING in /opt/apache-httpd-2.2.22/htdocs_demo/xmltest.php on line 1

I want to fix the problem in server2.

Which settings do I have to check?

Server1 is Windows7(64bit)+Apache2.2.17(32bit)+PHP5.3.14(32bit)

Server2 is CentOS6.4(64bit)+Apache2.2.22(64bit)+PHP5.3.14(64bit)

Upvotes: 0

Views: 26

Answers (1)

C3roe
C3roe

Reputation: 96339

Your “second server” has short_open_tag enabled, which makes it think <? opens a PHP block, and after that it finds xml, which is not a valid PHP expression.

Either disable it, or output <?xml via PHP in the first place to avoid this.

Upvotes: 1

Related Questions