hinkphp查询mssql数据库出现乱码的原因是ThinkPHP默认为UTF-8,而msmsql数据库是简体中文版,存储的是GB2312编码
解决方法:
1:在ThinkPHP\Lib\Core 打开Db.class.php,在其最后面加上
2:在Db.class.php找到function select(),在$result = $this->query($sql);后面加一条 $result=iconv2utf8($result),就OK了
[PHP]代码
public function iconv2utf8($Result) {
$Row=array();
$key1=array_keys($Result); //取查询结果$Result的数组的键值
//print_r($key1);
$key2=array_keys($Result[$key1[0]]);
//取查询结果$Result的第一个数组($key1[0])的键值
//print_r($key2);
for($i=0;$i<count for retrun><p> </p>
<p></p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20e352aa140.jpg" alt="Build MCP servers and clients for PHP applications with the official PHP SDK" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK" class="overflowclass">Build MCP servers and clients for PHP applications with the official PHP SDK</a>
<p class="overflowclass">使用官方Model Context Protocol PHP SDK将PHP应用程序功能暴露为MCP工具、资源和提示,用于代理工作流。</p>
</div>
<a rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>
<p> </p></count>
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










