php用urlencode、urldecode解决汉字乱码问题
有时候数据库中存了汉字,取出来之后变成了乱码,可以用urlencode、urldecode这两个函数来解决这个问题,例如:
$statuses=M('information_sheet')->where(array('Id'=>$newsid))->field('List_ID,Id,CreateDate,Theme,pic_urls')->find();我从表information_shee中取出了List_ID,Id,CreateDate,Theme,pic_urls这几个字段的数据,其中Theme这个字段的数据是汉字,如果我不做处理,直接echo json_encode()输出的话,就会得到乱码,可以这样解决:
$statuses[0]['Theme']=urlencode($statuses[0]['Theme']); 用urlencode对中文进行编码
输出的时候为:
echo urldecode(json_encode($statuses)); 用urldecode解码,就可以得到正确的中文了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
