本文整理汇总了PHP中captcha::display方法的典型用法代码示例。如果您正苦于以下问题:PHP captcha::display方法的具体用法?PHP captcha::display怎么用?PHP captcha::display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类captcha
的用法示例。
在下文中一共展示了captcha::display方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
{
/* Display Captcha */
public function display($width, $height, $text)
{
/* Create Image */
$image = imagecreate($width, $height);
/* Set Background */
$bg = imagecolorallocate($image, 255, 255, 255);
/* Set Text Color */
$color = imagecolorallocate($image, 0, 0, 0);
/* Patch together Image */
/* First character */
$r = rand(-25, 25);
imagettftext($image, 26, $r, 10, 33, $color, "fonts/arial.ttf", substr($text, 0, 1));
/* Each character after that */
for ($i = 0; $i <= strlen($text); $i++) {
$part = substr($text, $i + 1, 1);
$r = rand(-25, 25);
$x = 36 + 26 * $i;
imagettftext($image, 26, $r, $x, 37, $color, "fonts/arial.ttf", $part);
}
/* Output the image */
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
}
}
$captcha = new captcha();
session_start();
echo $captcha->display("170", "50", $_SESSION['captcha']);
示例2: captcha
//////////////////////////////////////////////////////////////////////////////////////////////////
// make image
/**
* the time() at the end of the address is just to keep the image from being cached
* <img id="captcha_img" src="./captcha/cf.captcha.php?img=<?=time();?>" />
*
*/
if (isset($_GET['img'])) {
$capt = new captcha();
if (isset($_GET['bg'])) {
//$capt->transparent_bg(false);
//$capt->bg_color($_GET['bg']);
$capt->colorshad = 'd';
}
$capt->add_wave();
$capt->display();
exit;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// captcha Class
class captcha
{
private $UserString;
/**
* The width of the captcha image
* @var integer
*/
private $width = 120;
/**
* The height of the captcha image
* @var unknown_type
示例3: display
/**
* @description Displaying/saving captcha
* @repeat 20
*/
function display()
{
captcha::display($this->captchaid, $this->getTempFile('png'));
}