Skip to content

XML file being processed by PHP causes syntax error (Invalid: short tags were enabled) #13033

@SVGAnimate

Description

@SVGAnimate

Description

The following code:

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to><?php echo "Is this valid PHP"; ?></to>
  <body>This is valid XML</body>
</note>

Resulted in this output:

Parse error: syntax error, unexpected identifier "version" in /home/user/scripts/code.php on line 1

But I expected this output instead:

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Is this valid PHP</to>
  <body>This is valid XML</body>
</note>

Why should I have an echo?

<?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
<note>
  ...
</note>

PHP Version

PHP 8.0.30

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions