PHP GD图像生成中断


PHP GD Image generation broken

我的PHP图像代码需要帮助。我试图制作Captcha,但我得到的只是破碎的图像图标?

这是我的代码:

<?php 
header('Content-type: image/jpeg'); 
$text = "1111"; 
$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); 
imagettftext($image, $font_size, 0, 15, 30, $text_color, 'font.ttf', $text); 
imagejpg($image); 
?>

"font.ttf"在我的php文件旁边,名称与

匹配

使用

imagejpeg($image); 

代替

imagejpg($image); 

由于imagejpg()不存在。

调试时,您应该注释掉标头以查看错误。