$textcolor = Imagecolorallocate ($img, 255, 0, 0); Set Watermark Font Color
$font = ' C:/windows/fonts/simhei.ttf '; Defining fonts
$text = Iconv ("GB2312", "UTF-8", $WATERIMAGEURL); Convert Chinese text to UTF8
Imagettftext ($img, $textcolor, $font, $text);//write the text in the picture
$this->outputimage ($img, $this->getextendsname ($IMAGEURL), $IMAGEURL);
Imagedestroy ($img);///Destroy images
In many cases, the problem is such a solution, but, you don't forget, there are special circumstances, that is, you set the PHP page encoding, such as: Header ("content-type:text/html; Charset=utf-8 ");
, well, at this time, you still use this way, that will die, the same will garbled, why, because it is already UTF-8, you turn what ah? Not disorderly only strange, at this time, can be removed from the third line, the Imagettftext method directly to the $text to $waterimageurl, of course, there is a more special situation, that is, you pass the value of the page is another code, rather than UTF-8, that estimates there are articles, so, I would like to advise you to learn PHP friends, it is best to ensure that your site each page encoding consistent, so that the problem to solve a lot easier.
Or put the code, afraid some people do not know, www.2cto.com
$textcolor = Imagecolorallocate ($img, 255, 0, 0); Set Watermark Font Color
$font = ' C:/windows/fonts/simhei.ttf '; Defining fonts
$text = Iconv ("UTF-8", "UTF-8", $WATERIMAGEURL); Convert Chinese text to UTF8
As you can actually see, there's no need to go, because I've already set the encoding to UTF-8 in the previous index.php file, if
Written AS//$text = Iconv ("GB2312", "UTF-8", $WATERIMAGEURL); Instead, it will appear garbled.
$text = $WATERIMAGEURL;
Imagettftext ($img, $textcolor, $font, $text);//write the text in the picture
$this->outputimage ($img, $this->getextendsname ($IMAGEURL), $IMAGEURL);
Imagedestroy ($img);///Destroy images
Excerpted from 0+0+0+...=1
http://www.bkjia.com/PHPjc/478455.html www.bkjia.com true http://www.bkjia.com/PHPjc/478455.html techarticle $textcolor = imagecolorallocate ($img, 255, 0, 0);//Set watermark font Color $font = C:/windows/fonts/simhei.ttf;//define Font $text = Iconv (GB2312, UTF-8, $WATERIMAGEURL); Will be in ...