課程
/后端開發
/PHP
/PHP進階篇
亂碼中,亂碼中
2015-06-30
源自:PHP進階篇 8-6
正在回答
<?php$img = imagecreatetruecolor(100, 40);$black = imagecolorallocate($img, 0x00, 0x00, 0x00);$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);imagefill($img,0,0,$white);//生成隨機的驗證碼$code = '';for($i = 0; $i < 4; $i++) {??? $code .= rand(0, 9);}imagestring($img, 5, 10, 10, $code, $black);//加入噪點干擾for($i=0;$i<50;$i++) {? imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black); ? imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green);}//輸出驗證碼header("content-type: image/png");imagepng($img);imagedestroy($img);
yunsky0 提問者
舉報
輕松學習PHP中級課程,進行全面了解,用PHP快速開發網站程序
3 回答中文亂碼問題
1 回答加入header("content-type:text/html; charset=utf-8");echo不亂碼,但是數據庫查詢就亂了
2 回答加了mysql_query("SET NAMES 'UTF8'"); 網頁上還是顯示亂碼
3 回答我自己搭建的環境 查詢數據庫亂碼啊 ?。?!誰能幫幫我!
3 回答代碼中的<\/li>是什么意思
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-12-25
<?php
$img = imagecreatetruecolor(100, 40);
$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
$green = imagecolorallocate($img, 0x00, 0xFF, 0x00);
$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
imagefill($img,0,0,$white);
//生成隨機的驗證碼
$code = '';
for($i = 0; $i < 4; $i++) {
??? $code .= rand(0, 9);
}
imagestring($img, 5, 10, 10, $code, $black);
//加入噪點干擾
for($i=0;$i<50;$i++) {
? imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black);
? imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green);
}
//輸出驗證碼
header("content-type: image/png");
imagepng($img);
imagedestroy($img);