private static function writeText() { if (self::$shapeType == 2) { //这里是上右下左类型 $order = array('上', '右', '下', '左'); //随机打乱数组,键不变 shuffle($order); $n = floor(self::$width / 4); $i = 0; foreach ($order as $key => $fontOrder) { switch ($fontOrder) { case '上': $x = $n + 10; $y = 0; break; case '左': $x = 10; $y = $n; break; case '右': $x = 2 * $n + 10; $y = $n; break; case '下': $x = 1 * $n + 10; $y = 2 * $n - 5; break; } self::$orderArray[$fontOrder] = self::$codeStringArray[$i]; if (self::$fontTextShow) { $offset = self::$codeType != 4 ? 5 : -10; if (self::$shapeType == 2 && (self::$codeType = 4)) { $offset = 10; } imagettftext(self::$img, 10, mt_rand(-10, 30), $n * $i, $n * 3 + $offset, self::autoFontColor(), self::$fontType, $fontOrder); } if (self::$shapeType == 2 && (self::$codeType = 4)) { $y = $y + 15; } self::chineseOrEng(self::$codeType, $x, $y, $i); $i++; } } else { if (self::$shapeType == 1) { //这里是常规验证码类型 for ($i = 0; $i < self::$codeNum; $i++) { if (self::$codeType != 4) { $x = floor(self::$width / self::$codeNum) * $i + 3; $y = mt_rand(0, self::$height - 20); } else { $x = floor(self::$width / self::$codeNum) * $i; $y = mt_rand(20, self::$height - 10); } self::chineseOrEng(self::$codeType, $x, $y, $i); } self::dian(); } } }