本文整理汇总了PHP中captcha::createCaptcha方法的典型用法代码示例。如果您正苦于以下问题:PHP captcha::createCaptcha方法的具体用法?PHP captcha::createCaptcha怎么用?PHP captcha::createCaptcha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类captcha
的用法示例。
在下文中一共展示了captcha::createCaptcha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCaptcha
public function createCaptcha()
{
$captcha = '';
$symbol = '0';
$width = 420;
$height = 70;
$font = 'fonts/bellb.ttf';
$fontsize = 20;
$captchaLength = rand(1, 1);
$im = imagecreatetruecolor($width, $height);
$bg = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $bg);
for ($i = 0; $i < $captchaLength; $i++) {
$captcha .= $symbol[rand(0, strlen($symbol) - 1)];
$x = ($width - 20) / $captchaLength * $i + 10;
$x = rand($x, $x + 4);
$y = $height - ($height - $fontsize) / 2;
$curcolor = imagecolorallocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
$angle = rand(-25, 25);
imagettftext($im, $fontsize, $angle, $x, $y, $curcolor, $font, $captcha[$i]);
}
session_start();
$_SESSION['captcha'] = $captcha;
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
}
$obj = new captcha();
$obj->createCaptcha();
示例2: captcha
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
define("captchaCode", "");
include 'captcha.class.php';
if (isset($_GET['aux'])) {
$aux = $_GET['aux'];
} else {
$aux = "0";
}
if (isset($_GET['input_captcha'])) {
$input_captcha = $_GET['input_captcha'];
} else {
$input_captcha = "0";
}
if ($aux == 'createCaptcha') {
$captcha = new captcha("fonts/");
$htmlCaptcha = $captcha->createCaptcha();
echo $htmlCaptcha;
} else {
if ($aux == 'validateCaptcha') {
if ($input_captcha != "0") {
$captcha = new captcha();
$validCaptcha = $captcha->validateCaptcha($input_captcha);
echo $validCaptcha;
}
}
}