How do I load a SVG file that's been generated with PHP?

前端 未结 1 1059
悲&欢浪女
悲&欢浪女 2021-01-06 02:26

I want to create a SVG file with PHP, and then include it in a HTML file. Here\'s what I have so far (following this tutorial)

svg.php:

<         


        
相关标签:
1条回答
  • 2021-01-06 03:09

    GeoPhoenix answered above, I figured I'd put it into an answer so that there's an offical one:

    if you remove the <?xml?> line it renders the svg

    PHP can see <? as the opening tag for PHP code (rather than an XML declaration), thanks to the short-open-tag setting (thanks to fvu). This is an easy fix, I just replaced

    <?xml version="1.0" encoding="iso-8859-1"?>
    

    with

    <?php echo '<?xml version="1.0" encoding="iso-8859-1"?>';?>
    

    This has the same intended result and doesn't cause syntax errors.

    0 讨论(0)
提交回复
热议问题