imagestring($image,6 , 30, 10, $newCode, $red);
2017-05-05
//干擾線
for($j=0;$j<3;$j++){
$x = mt_rand(0, $width);
$y = mt_rand(0, $height);
$xx = mt_rand(0, $height);
$yy = mt_rand(0, $height);
imageline($image, $x, $y, $xx, $yy, $red);
}
for($j=0;$j<3;$j++){
$x = mt_rand(0, $width);
$y = mt_rand(0, $height);
$xx = mt_rand(0, $height);
$yy = mt_rand(0, $height);
imageline($image, $x, $y, $xx, $yy, $red);
}
2017-05-05
很多老的 libc 的隨機數(shù)發(fā)生器具有一些不確定和未知的特性而且很慢。PHP 的 rand() 函數(shù)默認(rèn)使用 libc 隨機數(shù)發(fā)生器。mt_rand() 函數(shù)是非正式用來替換它的。該函數(shù)用了 » Mersenne Twister 中已知的特性作為隨機數(shù)發(fā)生器,它可以產(chǎn)生隨機數(shù)值的平均速度比 libc 提供的 rand() 快四倍。 所以用mt_rand() 能用mt的函數(shù),就用mt的
2017-05-05
<p>驗證碼圖片:
<img id = "captcha_img" border = "1" src="./captcha.php?r=<?php echo rand();?>"width:100px,height:100px" />
<a href="javascript:void(0)" onclick="document.getElementById('captcha_img').src='./captcha.php?r='+Math.random()">換一個</a>
</p>
<img id = "captcha_img" border = "1" src="./captcha.php?r=<?php echo rand();?>"width:100px,height:100px" />
<a href="javascript:void(0)" onclick="document.getElementById('captcha_img').src='./captcha.php?r='+Math.random()">換一個</a>
</p>
2017-04-25
1.創(chuàng)建黑色畫布 $image = imagecreate(100, 30);
2.為畫布定義(背景)顏色 $bgcolor = imagecolorallocate($image, 255, 255, 255);
3.填充顏色 imagefill($image, 0, 0, $bgcolor);
4.向瀏覽器輸出圖片頭信息 header('content-type:image/png');
5.輸出圖片到瀏覽器 imagepng($image);
6.銷毀圖片 imagedestroy($image);
2.為畫布定義(背景)顏色 $bgcolor = imagecolorallocate($image, 255, 255, 255);
3.填充顏色 imagefill($image, 0, 0, $bgcolor);
4.向瀏覽器輸出圖片頭信息 header('content-type:image/png');
5.輸出圖片到瀏覽器 imagepng($image);
6.銷毀圖片 imagedestroy($image);
2017-04-25