免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2439 | 回复: 1

PHP网页乱码问题求助 [复制链接]

论坛徽章:
18
辰龙
日期:2014-05-21 21:01:4115-16赛季CBA联赛之深圳
日期:2016-12-23 13:51:3815-16赛季CBA联赛之北控
日期:2016-11-28 18:26:3815-16赛季CBA联赛之佛山
日期:2016-11-03 11:18:5815-16赛季CBA联赛之辽宁
日期:2016-07-10 16:09:4115-16赛季CBA联赛之江苏
日期:2016-02-20 23:09:202015亚冠之塔什干棉农
日期:2015-08-17 19:49:492015年亚洲杯之日本
日期:2015-04-30 01:24:342015年亚洲杯之约旦
日期:2015-04-01 00:37:182015年亚洲杯之沙特阿拉伯
日期:2015-03-02 15:55:40处女座
日期:2014-05-25 10:34:0020周年集字徽章-年
日期:2023-04-23 11:17:52
发表于 2014-10-21 11:10 |显示全部楼层
大家好!
我有一个问题向大家请教
请大家看下面一段操作记录:
[root@shanghai etc]# chsh apache
Changing shell for apache.
New shell [/sbin/nologin]: /bin/bash
Shell changed.
[root@shanghai etc]# su - apache
-bash-4.1$ cd html/download/test
-bash-4.1$ l
total 8
-rw-r--r--. 1 apache apache 86 Oct 21 17:46 phptest.php
-rwxr-xr-x. 1 apache apache 50 Oct 21 17:55 test.sh
-bash-4.1$ cat phptest.php
<?php
echo "<pre>";
system ("/var/www/html/download/test/test.sh");
echo "</pre>";
?>
-bash-4.1$ cat test.sh
#!/bin/sh
echo "Getting list of /tmp:"
-bash-4.1$ php phptest.php
<pre>Getting list of /tmp:
total 120
-rw-rw-rw-. 1 mysql mysql 121423 Oct 21 09:40 testfile.txt
</pre>-bash-4.1$ ./test.sh
Getting list of /tmp:
total 120
-rw-rw-rw-. 1 mysql mysql 121423 Oct 21 09:40 testfile.txt
-bash-4.1$ lynx -dump http://localhost/download/test/phptest.php
Getting list of /tmp:
total 0
-????????? ? ? ? ?            ? testfile.txt

ls -l /tmp
我想问一下,为什么直接执行test.sh或者执行php phptest.php都可以得到正常的输出。
而用lynx -dump http://localhost/download/test/phptest.php却会乱码呢?
我把php和httpd全部卸载以后重装,再试还是一样的乱码。
  1. [root@shanghai ~]# !lynx
  2. lynx -dump http://localhost/download/test/phptest.php|hexdump -C
  3. 00000000  47 65 74 74 69 6e 67 20  6c 69 73 74 20 6f 66 20  |Getting list of |
  4. 00000010  2f 74 6d 70 3a 0a 74 6f  74 61 6c 20 30 0a 2d 3f  |/tmp:.total 0.-?|
  5. 00000020  3f 3f 3f 3f 3f 3f 3f 3f  20 3f 20 3f 20 3f 20 3f  |???????? ? ? ? ?|
  6. 00000030  20 20 20 20 20 20 20 20  20 20 20 20 3f 20 74 65  |            ? te|
  7. 00000040  73 74 66 69 6c 65 2e 74  78 74 0a                 |stfile.txt.|
  8. 0000004b
  9. [root@shanghai ~]#
复制代码
在Windows下用IE访问也是一样的乱码。
而且我在test.sh里加上一个cat /tmp/testfile.txt以后用./test.sh或者php phptest.php都可以正常执行。
但是通过浏览器访问,这个命令没有被执行。

[root@shanghai test]# cat test.sh
#!/bin/sh
echo "Getting list of /tmp:"
ls -l /tmp
cat /tmp/testfile.txt
[root@shanghai test]# ./test.sh
Getting list of /tmp:
total 4
-rw-rw-rw-. 1 mysql mysql 12 Oct 21 19:02 testfile.txt
Hello World
[root@shanghai test]# php phptest.php
<pre>Getting list of /tmp:
total 4
-rw-rw-rw-. 1 mysql mysql 12 Oct 21 19:02 testfile.txt
Hello World
</pre>[root@shanghai test]#  lynx -dump http://localhost/download/test/phptest.php
Getting list of /tmp:
total 0
-????????? ? ? ? ?            ? testfile.txt

[root@shanghai test]#
是什么地方没有设置正确吗?我在其他的服务器上也测试了这两个脚本都没有出现乱码的情况。
服务器版本是RHEL6.5。
谢谢。

论坛徽章:
0
发表于 2014-10-21 16:53 |显示全部楼层
看看文件编码和数据库里的编码是否一致
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP