2014-09-29 42 views
-2

這PHP代碼追加兩行到文件:PHP imagepng雙FWRITE

$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); 

例輸出一個瀏覽到文件:
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端點

因爲那裏使用將觸發 debug.php文件,我相信重新加載

回答

1

new Image().src是你的圖像生成的URL 。您正在觸發圖像的第二次加載,因此有兩行。

+0

我測試了它沒有javascript,只需鍵入url到browser.Hmm,火狐v32重現這一點,但鉻v37不!這是一個Firefox錯誤? – 2014-09-29 20:58:25

+0

和javascript代碼在另一個文件中,例如html5.js,而不是在debug.php中 – 2014-09-29 21:05:32