1
我对我的验证码有以下代码。生成图像中的线条,但不显示4位数字。我假设有一些问题imagettftext函数不能在php中工作
imagettftext($ image,$ font_size,0,15,30,$ text_color,'font.TTF',$ text);
代码的功能。我尝试使用$ _server ['DOCUMENT_ROOT']设置字体文件的路径;但没有工作。
下面的代码:
<?php
session_start();
header('Content-type: image/jpeg');
$text= $_SESSION['secure'];
$font_size =30;
$image_width= 110;
$image_height=40;
$image=imagecreate($image_width,$image_height);
imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);
for($x=1; $x<=30; $x++){
$x1 = rand(1,100);
$x2 = rand(1,100);
$y1 = rand(1,100);
$y2 = rand(1,100);
imageline($image, $x1, $x2, $y1, $y2, $text_color);
}
imagettftext($image,$font_size,0,15,30,$text_color,'font.TTF',$text);
imagejpeg($image);
?>
对不起,我不明白你实际上是想说什么? – user1460822 2012-08-05 09:18:43
看到这个网址http://stackoverflow.com/questions/8496809/why-isnt-the-php-imagettftext-function-working-in-this-case – 2012-08-05 09:19:51
看到这两个网址http://stackoverflow.com/questions/ 7034698/imagettftext-not-working – 2012-08-05 09:21:33