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

May 17, 2020 pm 05:13 PM

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)