PHP编码问题

在项目中经常出现后端代码存储到数据库乱码,后台代码读取数据库乱码,有没有办法解决这些问题,并让项目统一解决。

lin5_mumu
浏览 1619回答 4
4回答

weibo_那我说天真应该是好_0

会有许多情况导致乱码,为保万无一失请基本做到以下步骤:代码编辑器的编码设置为UTF-8无BOM模式。数据库中设置库,表,字符字段的编码格式都为utf8_general_ci浏览器的编码设置为utf8

HuoSiRen

再写代码时先统一编码为utf-8

慕婉清5044891

ACDZJLBQTPFBKMIRAJLVXNZHWMJXZVRNJUQZOKGILHQSXSPFULBDGDSBDMPLHRTCZBUJFVRHYUOYABETWLIRZBZVXZIXGCMBVMBVXTVLNWSOKZLHPFHQAJSVDAWENWSIJLBXLTJFOQZIJFPMHQZVWYADZINPEOQSVDACZIXRHQSOFALAMVXTIRAPXZJDSBPSAYGWFIDSVYAXNCYAIJRGHWTIEGJFRUPYAJSIYAQZOIKGCFAJFBHCLAOXZIKNVKTVXGJSNDZCVXXTPSIEAWRTCLACFHKYHWCLGJSHXTVRBBKTCRAQGBDSPLZILAJZIRNLGIYNPMBJGBGVENDMODZILPRZPQSBKTCKCYNWSUXZCYTADSHQZIXGWSOJSHQZIKNQFOQMCEFHJZIMOOQZVEGQMQMPKTCEAWFORZYBDMCFMCRNPLNPYNDFOKACHWENCDFBENRTVRFOWFUDMIFHWZIRHJGPRENXZWQTQZWLWYAJZHKZPEBFHJYNXGADMBKNPLMORAWAPLUCSBCSOXZCBDFVRNWYGPFIDSOEGAJZBKIDEGPMIKAJFYODZIPFAJZOTIRACFUKZDZVXMCLAWYUKZRMIEUXAPSHQPRGWSNDGIRFIYTWYUKGCZBWFIETWRADTPIXSPEHQSOYUTVRGPYSORUDZODTCYHJMIEFTJYBRTCFVRDSOKSTVKAQFIRMCENCSGJFPKGISVKTISPPXTCDFVSAKZBQSHKMVRAVRQYFVKTIYNDFFBQFOKGVRZBIETXZBEABXTLODLNWFAJZIQSBKGWSBDMBRUJSHWFIRMBJYNCFHKZIFOODSGJLOEADLWLACYODGILUMUDSTJFVYILFHPFOETIWZCKGOXSCLADFBWMUQZOEMVRH

翱睿

编码都解决不了,会用数据库??

KevenHuang

只要在操作数据库之前设置好和数据库一致的编码就行了,mysql_query("set names utf8");问题就得以解决了,望采纳。
打开App,查看更多内容
随时随地看视频慕课网APP