Two ways to set php encoding for loading pages: php loading page encoding _ PHP Tutorial

Source: Internet
Author: User
Two methods are used to set the encoding when php loads the page. php loads the page encoding. Two methods are used to set the encoding when php loads the page. php loads the page encoding. php loads the page encoding. one is the output meta tag: 1. in the phpmvc controller, or in two ways to set the php encoding when loading the page, php loads the page encoding

Two methods for setting page encoding when php loads a page

1: output meta tag:

1. echo' ';
2. on the php page or html page

2: Use the 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", ""); // Three database connection parameters: web server, database account, and password. \

Mysql_select_db ("lyb"); // select a database
Mysql_query ("set names gb2312") // sets transmission to use the gb2312 character set to prevent garbled characters.
?>

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

PHP page encoding

Because the page code you created is UTF-8, even if you deleteThe encoding settings are UTF-8.
If you need a uniform gb2312
1. when creating the dw page, select the new page encoding as gb2312 as the preferred parameter.

2. ctrl + j re-modify the file encoding

Php does not have the encoding problem except the database data because php does not have Chinese characters .. As long as the page settings are incorrect
 

Two methods for setting page encoding when loading a page in php: output meta tag: 1. in the controller of php mvc or...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.