代码如下<?php
//$str = $_REQUEST['str'] ? $_REQUEST['str']:"暂无输入";
$a1=$_GET["a1"];
$im = imagecreate(240,220);
$white = imagecolorallocate($im,0xFF,0xFF,0xFF);
imagecolortransparent($im,$white);  //imagecolortransparent() 设置具体某种颜色为透明色,若注释
$font="simkai.ttf";
imagettftext($im,15,0,45,120,$black,$font,"幼稚度:".$a3."%"); 
imagettftext($im,15,0,45,160,$black,$font,"成熟度:".$a4."%"); 
imagettftext($im,15,0,45,200,$black,$font,"成熟度:".$a5."%"); 
header("Content-type:image/png");
imagepng($im);?>
运行以后。结果显示如下:

解决方案 »

  1.   


    header("Content-type: image/png");
    $im = imagecreate(240,220);
    $white = imagecolorallocate($im,0xFF,0xFF,0xFF);
    $font_color = imagecolorallocate($im, 0,0,255);
    $font="/usr/share/fonts/truetype/myfonts/msyh.ttf";
    imagettftext($im,15,0,45,120,$font_color,$font,iconv('gbk','UTF-8',"幼稚度:1%")); 
    imagettftext($im,15,0,45,160,$font_color,$font,iconv('gbk','UTF-8',"幼稚度:1%")); 
    imagettftext($im,15,0,45,200,$font_color,$font,iconv('gbk','UTF-8',"幼稚度:1%")); 
    imagepng($im);
    iconv 字符转换是必须的