Reputation: 28138
I am using PHP inside an SVG file, to adjust colours and whatnot, with PHP variables. The file is saved with a .php
extension.
The problem is, the first line of an SVG file is wrongly interpreted by VS Code, it keeps complaining that I have to add;
characters in this line:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Error in line 1:
';' expected at 1,6
';' expected at 1,10
';' expected at 1,37
How can I tell VS Code to allow SVG XML declarations?
Upvotes: 1
Views: 458
Reputation: 53626
You don't: that error is 100% correct. If this is a PHP file, you're going to need to explicitly echo that XML declaration, as <?
is a shorthand code for entering PHP mode.
You really do need to change your code in this case, e.g.:
<?php
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
?>
<svg version="..." xmlns="..." ...>
<!-- normal SVG code here -->
<?php
// intermixed with more php code
?>
...
</svg>
Upvotes: 2