天天看點

php圖像因存在錯誤而無法顯示

php圖像因存在錯誤而無法顯示

(上圖為火狐浏覽器顯示,google浏覽器顯示一個叉叉)

1 2 3 4 5 6 7 8 9

<?php

header(

"Content-type:image/jpeg"

);

$resource

=

fopen

(

'001.png'

,

'r'

);

while

(

$ff

=

fread

(

$resource

, 1024)){

$file

.=

$ff

;

};

echo

$file

;

原因分析:因為存在一個notice錯誤。

$file .= $ff;

原型為:

$file = $file.$ff;

中間的$file沒有定義,會報錯

解決方法:

方案一:關閉wamp的notice錯誤提示。

1

error_reporting

(E_ALL & ~E_NOTICE);

方案二:在前面定義下$file=”;

php