php imagepng与双fwrite

时间:2014-09-29 20:01:19

标签: php image fwrite

这个php代码将两行附加到文件:

$t = microtime();
$fn = $DOCUMENT_ROOT."/test.txt";
$f = fopen($fn, "a");
fwrite($f, "\n". $t);
fclose($f);

header('Content-Type: image/png');
$im = imagecreatetruecolor(1,1);
imagepng($im);
imagedestroy($im);

使用ONE浏览文件的示例输出:
0.43408600 1412017949
0.46703300 1412017949

我希望代码只需在ONE浏览中追加一行。

(imagejpeg或imagegif比imagepng快?)

// This is an javascript debug trick:
new Image().src = "http://d_o_m_a_i_n/debug.php?p=msg";

请参阅facebook sdk端点

1 个答案:

答案 0 :(得分:1)

使用

new Image().src会触发debug.php文件的重新加载,我认为该文件是图像生成器的URL。您触发了第二次图像加载,因此有两行。