不知是字符集的有关问题还是算法有关问题

WBOY
Release: 2016-06-13 11:19:56
Original
846 people have browsed it

不知是字符集的问题还是算法问题

<br />for($r=1;$r<=$rows;$r++){<br />    for($n=$rows;$n>$r;$n--){<br />	echo "&nbsp";<br />	}<br />    for($m=0;$m<$r ;$m++){<br />	echo "*";<br />	}<br />echo "<br>";<br />}
Copy after login

为了实现
但是现在变成了

是我算法的问题吗?我用IE浏览器打开,默认GB2312字符集的话显示的就是正确的,UTF-8显示的就是不对。
请问是字符集的问题才出现这样的情况吗,如何解决?谢谢!~


------解决方案--------------------
当然不是算法问题!
本来这种题目是在文本方式下测试的,你放到html中当然是要有些问题的
$rows = 12;<br />echo '<pre class="brush:php;toolbar:false">';<br />for($r=1;$r<=$rows;$r++){<br />  for($n=$rows;$n>$r;$n--){<br />    echo " ";<br />  }<br />  for($m=0;$m<$r ;$m++){<br />    echo "*";<br />  }<br />  echo PHP_EOL;<br />}
Copy after login
这样就不变形了

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!