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


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

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

<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文件,使其看起来像这样,而结果不是这样。

请记住,我将使用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('Content-Type: image/png');