


How to solve the problem of garbled text and pictures in PHP? (Pictures + Videos)
This article mainly introduces to you the solutions to PHP Chinese garbled characters and image display garbled characters.
In the process of learning PHP, many novice friends must have encountered the problem of garbled characters. Solving the problem of garbled characters is not only a basic knowledge point that novices must master, but also the most common PHP interview. One of the questions.
Below we will summarize and introduce to you the solution when PHP encounters garbled characters based on simple code examples.
1. Chinese garbled characters on the PHP page
1. Header statement
<?php header("content-type:text/html;charset=utf-8"); //设置编码
When Chinese garbled characters appear on a PHP page , you can directly place this code in the head of the PHP page.
2. Change the php configuration file
First we open the php.ini configuration file
Find the corresponding location by searching for charset
Then change to "UTF-8"
Finally, reopen the PHP environment.
It should be noted here that when we use the first method, solving the garbled problem only takes effect on the current PHP page, while changing the configuration takes effect on all PHP pages.
2. The image displays garbled characters
To solve the problem of image displaying garbled characters, just add the following code to the header of the page, which is used to declare the image type.
<?php header("Content-Type:image/jpg");//图片编码设置
This article is an introduction to the solution to php garbled code and the solution to picture display garbled code. It is very simple. I hope it will be helpful to friends who need it. Helped!
If you want to know more about PHP, you can follow the PHP Chinese website PHP Video Tutorial, everyone is welcome to refer to and learn!
The above is the detailed content of How to solve the problem of garbled text and pictures in PHP? (Pictures + Videos). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor