优化 php8 兼容

This commit is contained in:
F4nniu
2026-10-25 12:18:02 +08:00
parent 9be9dd7e61
commit d9093aa8f1

View File

@@ -235,7 +235,9 @@ class Captcha
// 输出图像
imagepng($this->im);
$content = ob_get_clean();
if (PHP_VERSION_ID < 80000) {
imagedestroy($this->im);
}
return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/png');
}
@@ -338,8 +340,10 @@ class Captcha
// Resample
$bgImage = @imagecreatefromjpeg($gb);
@imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height);
if (PHP_VERSION_ID < 80000) {
@imagedestroy($bgImage);
}
}
/* 加密验证码 */
private function authcode($str)