php学习笔记
	
    
    
	 1、$_SERVER['SCRIPT_NAME']、$_SERVER['PHP_SELF']和$_SERVER['REQUEST_URI']区别
例子:http://localhost/phpwind75/test.php/%22%3E%3Cscript%3Ealert(’xss’)%3C/script%3E%3Cfoo
$_SERVER['SCRIPT_NAME']只获取脚本名,不获取参数,输出结果为:test.php;
$_SERVER['PHP_SELF']获取脚本名后,同时获取参数数据,并对参数数据进行一次urldecode操作,易出现跨站攻击现象,输出结果为:
"><script>alert('xss')</script><foo
$_SERVER['REQUEST_URI']获取脚本名后,同时获取参数原始数据,操作结果为:
test.php/%22%3E%3Cscript%3Ealert(’xss’)%3C/script%3E%3Cfoo
2、urldecode与rawurldecode区别
urldecode将"+"解析为" ",而rawurldecode则不解析
3、&&与||优先级问题
&&级别比||高
4、全局变量问题
如果在同一个文件内$a= $_GLOBALS[a];
在函数中如果要引用全局变量则必须:global $a;否则只是私有变量
例如:
global $a;
$a=2;
function test(){
       echo $a;
}
test();
 
这个结果将为空
而
global $a;
$a=2;
 
function test(){
       global $a;
       echo $a;
}
 
test();
 
这个结果将为:2,
如果使用$_GLOBALS[a]的话,则结果也为2:
global $a;
$a=2;
 
function test(){
       echo $GLOBALS[a];
}
 
test();
 
    
     
	
	
    
    
	相关文档:
        
    
    1.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在预定义变量(1)中;而链接到当前页面的的前一页面URL记录在预定义变量(2)中 
<?php
//本页地址,SCRIPT_NAME也可以
echo $_SERVER['PHP_SELF']."<br />";
//链接到当前页面的前一页面的 URL 地址:
echo $_SERVER ......
	
    
        
    
    一选择题:
1.下面的那个选项可以获取表单提交的值?(多选) b d
<form name='frm1' method="post">
<input type="text" name="name" ><input type="submit" name="a">
</form>
A.$_GET['name']
B.$_POST['name']
C.$_SESSION['name']
D.$_REQUEST['name']
E.$_GLOBAL['name']
2.忘啦。 ......
	
    
        
    
    1、mysql_connect()-建立数据库连接 {3RY4HVT?  
格式: Fv n:V\eb  
resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]]) _I;+p eq  
例: 1(V>8}zn  
$conn = @mysql_connect("localhost", "username", "password") or dir(" ......
	
    
        
    
    
void header ( string string [, bool replace [, int http_response_code]] )
void header ( string string [, bool replace [, int http_response_code]] )
header()是用来发送 HTTP Header的。replace是个可选的参数,指示是否替代一个先期相似的header,
 ......
	
    
        
    
    global定义一个全局变量,这个全局变量不是应用整个网站,而是应用与当前页面(包括require和include文件)文件。
$aa="test";
function test()
{
    global $aa;
    echo $aa;
}
test(); //print test
函数内定义的变量函数外可以调用,在函数外定义的的变量函数内不能使用。
gl ......