作者adddream (哆啦A孟)
看板PHP
標題Re: [請益] 關於gd畫圖
時間Fri Mar 16 11:49:38 2007
我把header("Content-type:image/fig");給註解
並加上ERROR_REPORTING(1)之後
browser還是沒反應耶,也沒出現錯誤訊息@@:
程式如下
<?php
$data="Menu.txt";
if(file_exists($data))
{
$fp=fopen($data,"r");
$old_count=fread($fp,filesize($data));
$new_count=$old_count+1;
fclose($fp);
}
else
{
$new_count=1;
}
$fp=fopen($data,"w");
fwrite($fp,$new_count);
fclose($fp);
//header("Content-type:image/gif");
//設定header以讓瀏覽器將檔案視為圖檔
//$im=ImageCreate(100,20); //產生一個空白圖
$im=@imagecreatefrompng("counter_bg.png") or die("can't build picture");
$red=ImageColorAllocate($im,255,0,0);
//第一個ImagecolorAllocate決定背景顏色
$white=ImageColorAllocate($im,255,0,255);
$yellow=ImageColorAllocate($im,255,255,255);
Imagestring($im,5,100,24,$new_count,$yellow); //為一字串影像,im像是一個容
器,ImageString像是內容物;前面的5表示使用的字型,
//後面兩個數字表示x,y的啟始位址
Imagestring($im,5,105,24,$new_count,$red);
Imagegif($im,"test.gif");
//輸出圖檔
ImageDestroy($im);
error_reporting(1);
//消毀圖片
?>
※ 引述《rocet (rocet)》之銘言:
: ※ 引述《adddream (哆啦A孟)》之銘言:
: : 因為我是用linux下的gvim去做編輯
: : 只能直接開web去做測試@@
: : 沒有半法得知錯誤在那裡耶@@
: 不是本來就用文字編輯器編輯完再用browser去測試嗎@_@
: 我的意思是把下面這行註解掉
: header("Content-type:image/gif");
: 再用browser開啟你的php程式
: 如果你是說你的php.ini就是設定成不會顯示任何錯誤的話
: 那可以加上一行 error_reporting(1)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.122.79.88
推 rocet:error_reporting(E_ALL); 加在程式最前面呢 03/16 11:51
→ adddream:是我呆嗎?我加到最前面了=.=,還是沒有畫面@@' 03/16 12:11