如何使图像悬停在另一个图像上并将其导出为图像

How to make an image hover over another and export it as an image

好的,我有一个问题。首先让我 post 这个:

<a href="#"><img src="http://i.imgur.com/ZRjnZlR.png" onmouseover="this.src='http://i.imgur.com/GPI0JA5.png'" onmouseout="this.src='http://i.imgur.com/ZRjnZlR.png'" /></a>

这是悬停在图像上的 html 代码。这很好用,唯一的问题是我不需要它作为 html 代码,但我想把它变成 php 文件,因为我在一个不允许的论坛上html.

那么,我如何将 html 代码变成 php,将结果结果变成 png 文件,使其看起来像 this and the outcome isn't this

记住,我将使用 bbcode 将悬停显示为图像。

导出图片,我的意思是header("Content-Type: image/png");

只需创建一个“.php”文件并在 php 代码中回显 html 代码:

<?php
    $img_src = 'http://i.imgur.com/ZRjnZlR.png';
    $mouseover_src = 'http://i.imgur.com/GPI0JA5.png';
    echo('<a href="#"><img src="' . $img_src .
        '" onmouseover="this.src=\'' . $mouseover_src . 
        '\'" onmouseout="this.src=\'' . $img_src . '\'" /></a>');

?>

编辑:

您可以使用 PHP "header()" 函数设置 header,如下所示:

header('Content-Type: image/png');