Ryan
Ryan

Reputation: 1164

Generating SVG files using PHP

So, I'm attempting to create some tag images for my users, showing the total points that they have earned. I am attempting to write the SVG in a php file which will add in dynamic content, such as the user's points. I'd like to use a HTML <img> tag to fetch the SVG from a file image_gen.php.

How would I display the SVG through the <img> tag?

Thanks!

Upvotes: 5

Views: 6484

Answers (1)

Ryan
Ryan

Reputation: 1164

Using the following PHP code, I set the content type of the file to svg+xml:

<?php
    header('Content-Type: image/svg+xml');
?>

Upvotes: 7

Related Questions