嗯,首先我需要告诉你我对此很乐观。 我找到了一个生成验证码的php文件。 它的工作,但背景总是橙色和文字是黑色的。 示例验证码:“3ab6de”。我想要做的就是将背景颜色更改为另一种颜色,并使文本具有不同的颜色(3ab红色,6de蓝色)。 我试过但失败请帮助我的家伙! 这是代码:验证码的自定义颜色
<?php
session_start();
$random_alpha = md5(rand());
$captcha_code = substr($random_alpha, 0, 6);
$_SESSION["captcha_code"] = $captcha_code;
$target_layer = imagecreatetruecolor(70,30);
$captcha_background = imagecolorallocate($target_layer, 255, 160, 119);
imagefill($target_layer,0,0,$captcha_background);
$captcha_text_color = imagecolorallocate($target_layer, 0, 0, 0);
imagestring($target_layer, 5, 5, 5, $captcha_code, $captcha_text_color);
header("Content-type: image/jpeg");
imagejpeg($target_layer);
?>
谢谢!
对不起,我正在编辑我从互联网下载的原始php文件(而不是我的项目中的文件)。我的问题现在可以关闭。谢谢 ! –