亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

按照老師的來,我一開始沒有加入白點的時候,怎么背景也是全黑的

我除了有一個黑色的png,我的電腦整個背景都是黑色的

正在回答

5 回答

http://img1.sycdn.imooc.com//57e29ad10001b26312390882.jpg

<?php
?? ?
?? ?$image=imagecreatetruecolor(100,30);
?? ?
?? ?
?? ?$bgcolor = imagecolorallocate($image ,255,255,255);
?? ?
?? ?imagefill($image,0,0,$bgcolor);
?? ?
?? ?header('content-type:image/png');
?? ?imagepng($image);
?? ?
?? ?imagedestroy($image);
?? ?
?>

【??】為啥我的會出現這種情況?

0 回復 有任何疑惑可以回復我~
#1

chanson1216

哦哦,是瀏覽器問題
2016-09-21 回復 有任何疑惑可以回復我~

我真是,無奈了,我保證我什么都沒動,兩天過后我又打開,圖片就有了

0 回復 有任何疑惑可以回復我~

http://img1.sycdn.imooc.com//57412bd30001050205170327.jpg

這是我的圖片

0 回復 有任何疑惑可以回復我~

<?php
???? ?
??? session_start();
???? ?
??? $image=imagecreatetruecolor(100,30);//創建一個寬100,高30的圖片
?? $bgcolor=imagecolorallocate($image,255,255,255);
??? imagefill($image,0,0,$bgcolor);//將白色$bgcolor填充底圖,從左上角填充到右上角
?? ?
?/*? ?
???? for($i=0;$i<4;$i++) //增加數字
???? {??????????? ?
???? $fontsize=6;//定義數字的字體大小
???? $fontcolor=imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));//在這張圖片資源上申請一個顏色,就是數字的顏色
???? $fontcontent=rand(0,9);//數字的內容,隨機生成0-9
????? $x=($i*100/4)+rand(5,10);//坐標來標識隨機數字寫在哪里
????? $y=rand(5,10);
???? imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);//在$image的圖像資源上,畫隨機數字
??? }
*/
? $captch_code='';
?? for($i=0;$i<4;$i++)//增加字母和數字
{
????? $fontsize=6;
????? $fontcolor=imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));
???? ?

????? $data='abcdefghijkmnpqrstuvwxyz23456789';
????? $fontcontent=substr($data,rand(0,strlen($data)),1);
????? ?
?????? $captch_code.=$fontcontent;?? //將生成的內容加入到空字符$captch_code中
???? ?
?????? $x=($i*100/4)+rand(5,10);
?????? $y=rand(5,10);
???? imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
??? }
? $_SESSION['authcode']=$captch_code;



? for($i=0;$i<200;$i++)//增加200個以內的隨機點
{
???? $pointcolor=imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200));//生成點的顏色
???? imagesetpixel($image,rand(1,99),rand(1,29),$pointcolor);//
}
for($i=0;$i<3;$i++)//增加線
{
???? $linecolor=imagecolorallocate($image,rand(80,220),rand(80,220),rand(80,220));
???? imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor);
}
???? header('content-type: image/png');//表明輸出內容的格式
??? imagepng($image);//輸出&image
//end
? imagedestroy($image);//銷毀&image
?>




<?php
?header("content-type:text/html;charset=gb2312");
?if(isset($_REQUEST['authcode'])){
?session_start();
?if(strtolower($_REQUEST['authcode'])==$_SESSION['authcode']){
?echo '<font color="#0000CC">輸入正確</font>';
?}else{
?echo '<font color="#CC0000"><b>輸入錯誤</b></font>';
?}
?exit();
?}
?>


<!DOCTYPE html>
<html>
?? <head>
????? <meta charset="utf-8" />
?????? <title>確認驗證碼</title>
? </head>
? <body>
?????? <form method="post" action="./form.php">
?????????? <p>驗證碼圖片: <img border="1" src="./captcha.php?r=<?php echo rand();?>" width="100px" height="30px"></p>
?????????? <p>請輸入圖片中的內容: <input type="text" name="authcode" value=""/></p>
?????????? <p><input type="submit" value="提交"? style="padding:6px 20px;"></p>
?????? </form>
? </body>
</html>
????

0 回復 有任何疑惑可以回復我~

因為函數imagecreatetruecolor();返回的默認是以黑色為背景的

0 回復 有任何疑惑可以回復我~
#1

notmatter 提問者

那是圖片背景吧,老師的就是圖片是黑的,但是電腦背景是白的呀,我是圖片是黑的,背景也是黑的,然后圖片加入白點之后,圖片背景是白的了,但是,電腦大背景還是黑的呢,不過等我做到,,session那一節,又白了,好奇怪,不過我session那一節,字可以出來,但是驗證碼那張圖片出不來,你能給我看看么
2016-05-21 回復 有任何疑惑可以回復我~
#2

HxString 回復 notmatter 提問者

給你看什么?
2016-05-22 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

按照老師的來,我一開始沒有加入白點的時候,怎么背景也是全黑的

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號