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

藏色散人
Release: 2023-02-17 15:10:01
forward
3129 people have browsed it

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-标题"));
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Does php_redis.dll have PHP7.0?
From 1970-01-01 08:00:00
0
0
0
php7.0 array assignment problem reporting error
From 1970-01-01 08:00:00
0
0
0
Install php7.0 on ubuntu16.04LTS
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template