How to set the MySQL connection character set in php

怪我咯
Release: 2023-03-13 22:14:01
Original
4015 people have browsed it

Character is a general term for various characters and symbols, including characters of various countries, punctuation marks, graphic symbols, numbers, etc.Character set(Character set) is a collection of multiple characters. There are many types of character sets. Each character set contains a different number of characters. Common character set names: ASCII character set, GB2312 character set, BIG5 Character set, GB18030 character set, Unicode character set, etc. In order for a computer to accurately process text in various character sets, character encoding is required so that the computer can recognize and store various text. There are a large number of Chinese characters, and they are divided into two kinds of characters, Simplified Chinese and Traditional Chinese, with different writing rules. Computers were originally designed based on English single-byte characters. Therefore, encoding Chinese characters is the technical basis for Chinese information exchange. .

I always usedmysql_query("SET NAMES 'utf8'"); to set the default connection for MySQLCharacter set; but today I found a PHP recommendation The replacement for this method is thefunction

mysql_set_charset() that sets the MySQL connection character set.

This function is used like this:

mysql_set_charset('utf8', $link);
Copy after login

Returns TRUE on success and FALSE on failure.

The above is the detailed content of How to set the MySQL connection character set in php. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!