根据浏览器提供不同的图像?

Serve different images according to browser?

Chrome 无法正确呈现我的 SVG,因此我想改为提供 Chrome PNG。 SVG 在其他现代浏览器中看起来很漂亮,尤其是 iOS 上的 Mobile Safari,用户可能会通过捏合来放大 - 所以其他人得到的是 SVG,但 Chrome 得到的是 PNG。我该怎么做?

阅读the user agent string并有条件地提供内容:

<?php

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false)
{
    ?>
        <img src="mycontent.png">
    <?php
} else {
    ?>
        <svg>mycontent</svg>
    <?php
}

?>