PHP error in .xml file?

OK, firstly, I added this line to my .htaccess file, so the php engine parses the PHP code in the XML file:

AddType application/x-httpd-php .php .php3 .phtml .html .xml

After that, when I look at the XML file, I get this PHP error:

Parse error: parse error, unexpected T_STRING in /var/www/vhosts/mydomain.com/httpdocs/test.xml on line 1

But line 1 is not even php infact, it is line 1:

<?xml version="1.0" encoding="utf-8"?>

Can someone tell me what the problem is?

Thanks.

+3
source share
3 answers

This is because it <?is a short opening tag for php.

Try <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>

+10
source

, , , , PHP. :

  • XML PHP .htaccess.
  • xml PHP:

    <?php print('<?xml version="1.0" encoding="utf-8"?>'); ?>

  • short_open_tag .htaccess php.ini. , PHP <?php <?.

+6

4, : <? xml...? > .

'1.0 ' utf-8 XML, ; XML, .

+4

Source: https://habr.com/ru/post/1705730/


All Articles