Home  >  Article  >  Backend Development  >  php新人,中文乱码有关问题急求解答

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

WBOY
WBOYOriginal
2016-06-13 12:12:47917browse

php新人,中文乱码问题急求解答
我照着书上打了一串代码,功能是让用户输入一串字符然后打印出来。

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

结果如图,变量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