$_SERVER中常用变量的意思

三 15 2010 Published by zdy under 编程技巧

$_SERVER存储当前服务器信息

1,$_SERVER["QUERY_STRING"]
//查询(query)的字符串

2,$_SERVER["REQUEST_URI"]
//访问此页面所需的URI

3,$_SERVER["SCRIPT_NAME"]
//包含当前脚本的路径

4,$_SERVER["PHP_SELF"]
//当前正在执行脚本的文件名

比如:
打开页面http://www.jokejust.com/
$_SERVER["QUERY_STRING"] = “”
$_SERVER["REQUEST_URI"] = “/”
$_SERVER["SCRIPT_NAME"] = “/index.php”
$_SERVER["PHP_SELF"] = “/index.php”

打开页面http://www.jokejust.com/?p=22
$_SERVER["QUERY_STRING"] = “p=22″
$_SERVER["REQUEST_URI"] = “/?p=22″
$_SERVER["SCRIPT_NAME"] = “/index.php”
$_SERVER["PHP_SELF"] = “/index.php”

打开页面http://www.crazyi.cn/index.php?p=222
$_SERVER["QUERY_STRING"] = “p=222″
$_SERVER["REQUEST_URI"] = “/index.php?p=222″
$_SERVER["SCRIPT_NAME"] = “/index.php”
$_SERVER["PHP_SELF"] = “/index.php”

$_SERVER["QUERY_STRING"]获取查询语句,实例中可知,获取的是?后面的值
$_SERVER["REQUEST_URI"] 获取http://www.jokejust.com后面的值,包括/
$_SERVER["SCRIPT_NAME"] 获取当前脚本的路径,如:index.php
$_SERVER["PHP_SELF"] 当前正在执行脚本的文件名

No responses yet

关于javascript的一点注意事项,IE和FIREFOX 脚本的一些区别

十一 30 2009 Published by zdy under 编程技巧

window.addEventListener对IE不支持,IE使用window.attachEvent
但是老版本的IE就更麻烦了,至少我机子上的这个IE连attachEvent都不支持,直接用onload,onclick了。大家都支持

下面是在做sudo的时候使用的table

function creation(){
	var i,j;
	var table = document.createElement("table");
	var body = document.createElement("tbody");
	table.appendChild(body);
	for (i=1;i<10;i++){
		var tr = document.createElement("tr");
		for (j=1;j<10;j++){
			var td = document.createElement("td");
			var input = document.createElement("input");
			input.setAttribute("type","text");
			input.setAttribute("class","txt");
			input.setAttribute('className','txt');
			input.setAttribute("id","timu");
			input.setAttribute("name","timu");
			input.setAttribute("maxlength","1");
			td.appendChild(input);
			tr.appendChild(td);
		}
		body.appendChild(tr);
	}
	return table;
}

1.appendChild
其中需要注意的是,如果少了tbody这个标签,在IE中会出错

2.getElementByName
另外,因为调用每个表格时候,我用了document.getElementsByName(“timu”)
但是IE存在个bug是document.getElementsByName检索元素的ID不检索Name

3.setAttribute(‘style’,'color:red;’)
直接用object.style.color=red

4.class
input.setAttribute(“class”,”txt”);
input.setAttribute(‘className’,'txt’);//ie

No responses yet