Home > Backend Development > PHP Tutorial > Two ways to set the encoding when php loads the page, php loading page encoding_PHP tutorial

Two ways to set the encoding when php loads the page, php loading page encoding_PHP tutorial

WBOY
Release: 2016-07-13 10:21:59
Original
835 people have browsed it

Two ways to set the encoding when php loading page, php loading page encoding

Two methods to set the page encoding when PHP loads the page

1: Output meta tag:

1. In the php mvc controller or php page echo '';
2. In the php page or html page

2: Use header function

In the controller or page header("content-type:text/html; charset=utf-8");

How to set encoding in php

mysql_connect("localhost","root","");//Connect to the database with three parameters: web server, database account and password. \

mysql_select_db("lyb");//Select the database
mysql_query("set names gb2312") //Set the transmission to use the gb2312 character set to prevent garbled characters.
?>

Add mysql_query("set names gb2312") //Set the transmission to use the gb2312 character set to prevent garbled characters.

PHP page encoding problem

Because the encoding of your new page is utf-8, even if you delete the encoding setting in it is still utf-8
If you need unified gb2312
1.dw preferred parameters when creating a new page Select the newly created page encoding as gb2312

2.ctrl+j and re-modify the file encoding

Except for the data in the database, there is no encoding problem in PHP because PHP does not have Chinese. . As long as the page setting problem

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852377.htmlTechArticleTwo ways to set the encoding when php loads the page, php loading page encoding php sets the page when loading the page Two methods of encoding 1: Output meta tag: 1. In the controller of php mvc or...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template