Home>Article>Backend Development> How to set mssql to utf8 in php

How to set mssql to utf8 in php

藏色散人
藏色散人 Original
2021-06-01 09:02:25 2633browse

php method to set mssql to utf8: 1. Directly modify "mssql.charset to mssql.charset = "UTF-8""; 2. Pass "ini_set('mssql.charset', 'UTF-8" ');"Set utf8.

How to set mssql to utf8 in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php Set mssql encoding to solve the garbled problem mssql_connect charset Utf8?

When mssql is used to store data using nchar or nvarchar, because nchar or nvarcha does not support UCS-2 (that is, SQLServer will not store it in UTF-8 format)

will cause PHP to obtain The specific manifestation of garbled characters is: Chinese characters will become ???? This

and there is no method similar to mysql_query("set charset utf8");.

Solution:

1. Directly modify the php.ini file and directly modify mssql.charset to mssql.charset = "UTF-8"

2. You can also pass ini_set('mssql.charset', 'UTF-8');

Note that the utf-8 option is case-sensitive.

Recommended learning: "PHP Video Tutorial"

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

Statement:
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