Home >Backend Development >PHP7 >JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version

JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version

藏色散人
藏色散人forward
2020-05-17 17:13:543077browse

1.php7.0 version cannot display . Methods with the same name as their class will not be constructors in a future version of PHP:

JpGraph4.0.2 cannot display graphical reports correctly in PHP7.0 version.

The following error was obtained through php log:

JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version

Before modification:

JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version

will change the function LinePlot Changed to function __construct

After modification:

JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version

Reason: Before

php7.0, the method with the same name as the class can be regarded as a constructor method.

After php7.0, the constructor with the same name as the class will no longer be supported, and the constructor method will uniformly use __construct().

2. The Chinese title is garbled

Cause:

The default in JpGraph is to convert the string into utf8, but if your file It is utf8 itself and uses Chinese fonts. It will be converted once. As a result, if it is converted one more time, garbled characters will appear.

Solution:

Use the following encoding to convert all places where Chinese is used.

$graph->title->Set(iconv("UTF-8","GB2312//IGNORE","网志博客信息统计表"));
$graph->xaxis->title->Set(iconv("UTF-8","GB2312//IGNORE","X-标题"));
$graph->yaxis->title->Set(iconv("UTF-8","GB2312//IGNORE","Y-标题"));

Note:

Use the PHP function to convert Chinese data from UTF-8 to GB2312. Remember that due to a bug in iconv itself, iconv will make an error when converting the character "—" to gb2312. , so add "//IGNORE" after the encoding to be converted.

Recommended: "PHP7"

The above is the detailed content of JpGraph4.0.2 Chinese garbled characters and solutions that cannot be displayed in php7.0 version. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete