易截截图软件、单文件、免安装、纯绿色、仅160KB

php乱码问题

今天遇到了一个很奇怪的乱码问题,自己无意中解决了,但不知道是什么原因,只好记下来,防止以后再出现这样的问题。
当我把php语句写到下面的页面头信息之前的时候,这些php输出语句都输出的是乱码,包括用echo输出的js。如:echo "<script languge=javascript> alert('添加成功!');location.href = 'device_add.php';</script>";弹出来的“添加成功”也变成了乱码。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<LINK REL=stylesheet HREF="style.css" type="text/css">
<title>.............</title>
如果把php语句放到页面头信息之后,则不会出现乱码了。


相关文档:

PHP验证码生成脚本(5位数字png格式)


<?php
header("Content-Type:image/png");
srand((double)microtime()*1000000);
$img_height=20;
$img_width=60;
$im=@imagecreate($img_width,$img_height) or die("不能初始化GD文件流");
$background_color=imagecolorallocate($im,255,255,255);
$text_color=imagecolorallocate($im,233,14,91);
......

[PHP]Pear的使用

1. PEAR的安装, 这里介绍利用PHP5自带的BAT文件安装,需要能上网。
   a. 在PHP5目录下找到go-pear.bat,双击安装(保证能上网, 以便下载),BAT自动从网上下载PEAR所需的东西;
   b. 按照提示输入一些设置信息,主要是要把局域网的网关加上,如http://192.168.0.1:80/ , pear要用这个地址访问Interne ......

PHP计算页面执行时间

run_time.php  Code:
<?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0;
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function start()
{
$this->StartTime = $this->get_microtime();
}
f ......

linux下apache+php安装常见问题


configure: error: Unable to find libgd.(a|so)
如果使用的是ubuntu或debian就很简单了,直接sudo apt-get install apache2
libapache2-mod-php5 php5 php5-gd 就基本上搞定,但是用源代码安装还是很麻烦~
wget http://www.boutell.com/gd/http/gd-2.0.11.tar.gz
tar zxvf gd-2.0.11.tar.gz
cd gd-2.0.11
sudo . ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号