Home > Backend Development > PHP Problem > How to solve the problem of garbled characters in php odbc

How to solve the problem of garbled characters in php odbc

藏色散人
Release: 2023-03-14 08:52:01
Original
2410 people have browsed it

Solution to garbled odbc characters in php: 1. Modify "@header("Content-Type:text/html;charset=GB18030");"; 2. Change "".

How to solve the problem of garbled characters in php odbc

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

How to solve the problem of garbled characters in php odbc?

Problem description:

php uses ODBC to connect to sql server and outputs garbled characters! ! !

<?php
@header("Content-Type:text/html;charset=UTF-8");
$conn=odbc_connect(&#39;SQL&#39;,&#39;sa&#39;,&#39;sa&#39;);
if(!$conn)
echo "Fail";
$sql="select * from GoodSpec where GoodsNO=&#39;3316&#39;";
$result_id=odbc_do($conn, $sql);
$idno = odbc_result($result_id,2);
echo $idno; //这里输出乱码
odbc_close($conn);
?>
Copy after login

Solution:

@header("Content-Type:text/html;charset=GB18030");
Copy after login

Change it to this and it will be ok.

or

<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
Copy after login

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to solve the problem of garbled characters in php odbc. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template