我怎么會偶爾有生成三位驗證碼的情況
for($i=0;$i<4;$i++){//隨機4個字符
$fontsize = 6;
$fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));
$data = '0123456789abcdefghijklmnopqrstuvwxyz';
$fontcontent = substr($data,rand(0,strlen($data)),1);
$captch_code.=$fontcontent;
$x = ($i*100/4)+(rand(5,10));
$y = rand(5,10);
imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
}
2016-02-17
字符串第1位從0開始,字符串長度減1就解決問題了