PHP jpgraph Installation Tutorial To verify that the PHP environment supports the Jpgraph installation method of the PHP tutorial I mentioned the validation of the GD library, for the Jpgraph Chinese users to use jpgraph when not producing Chinese garbled is very necessary, And the GD library as a Jpgraph class library running in the PHP installation environment, the basis to ensure that the use of GD library does not appear in Chinese garbled is very necessary, before I verify the GD library on the Jpgraph class library support also appeared in the use of GD function Imagettftext function of Chinese garbled, The following is a description of the use of the PHP GD Library of Chinese garbled reasons and solutions.
PHP GD Library produces Chinese garbled reason
1, the server coding reasons . Because the Imagettftext function string parameter's default encoding is UTF8, if the server code is inconsistent, but does not carry on the corresponding character encoding format conversion, it is very easy to appear when uses the GD library output picture The Chinese character to become garbled.
2, did not choose the correct TTF font file . When using the GD library, if you want to output Chinese characters, you need to select the correct TTF font file.
PHP GD Library Chinese Garbled solution method
According to the previous introduction of the PHP GD library produced Chinese garbled principle, the solution of the PHP GD library Chinese garbled method is actually very simple.
1. It is recommended that the whole station use UTF8 code, if you have used GB2312 or GBK encoding, use Iconv or custom gb2312 and UTF8 conversion functions for character encoding conversion. gb2312 and UTF8 conversion functions please refer to the PHP Ajax transfer value of the character garbled how to solve.
2, if you are just a PHP environment, we recommend that the Apache configuration file in the default character set to UTF8, that is, Adddefaultcharset UTF8.
3, if the above method is not enough, please check whether you have added the –ENABLE-GD-JIS-CONV option when compiling the GD library, this option is to let the GD library support the Japanese-encoded font, please cancel this option and recompile. This method I did not verify, the estimate is mainly for UNIX installation configuration PHP environment. This is generally not the case for Windows environments, and it seems that the default PHP profile is commented out.
4, the use of PHP in the library generated Chinese garbled another reason is not to choose the correct TTF font, you need to choose to support Chinese fonts, commonly used in Chinese font files are SIMSUN.TTC and Simhei.ttf.
OK, as long as according to the above method, basically use PHP GD library to produce garbled Chinese can be solved. As long as the careful investigation of the GD library in Chinese garbled solution is very convenient.
Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.