Home >Backend Development >PHP Tutorial >php新人,中文乱码问题急求解答

php新人,中文乱码问题急求解答

WBOY
WBOYOriginal
2016-06-23 13:42:29777browse

我照着书上打了一串代码,功能是让用户输入一串字符然后打印出来。

<html><head><title> Building a From</title></head><body><?php$search=htmlentities($_POST["search"]);$self=htmlentities($_SERVER['PHP_SELF']);if($search===''){	echo('		<form action="'.$self.'" method="POST">		<label>搜索:<input type="text" name="search" /></label>		<input type="submit" name="anniu" value="搜索!"/>		</form>		');}else{	echo "您输入的是:$search";}?></body></html>

结果如图,变量search好像存不了中文:


在别人电脑上有的人也是同样结果,有的人却可以完美运行。。。
我用的sublime text3 存储为utf-8。急求大神解惑!


回复讨论(解决方案)

head 里面加上: 这句




 Building a From

不知道是不是头信息原因,如果是的话用PHP的header("Content-Type:text/html;charset=UTF-8");会比输出html标签好一些


nbsp;html>
 

这两不要忘

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
Previous article:微信调试问题Next article:mssql_query问题