作者previa ()
看板PHP
标题[请益] 关於php5 & Mysql5圣经
时间Tue May 2 23:30:29 2006
想请问一下 里面的有个地方 我不知道为什麽作者要用这个函式说 不知道动机为何@@
ps 这是出现在电子书的874页
<?php
//A file with the datebase host,user,password,and selected database
include_once('db_vars.inc');
//A string used for md5 encryption.You could move it to a file
//outside the web tree for more security
$supersecret_hash_padding = 'A string that is used to pad
out short strings for md5 encyption.';
$LOGIN_IN=false;
unset($LOGIN_IN);
<-有人知道为什麽这里要用unset func吗?
func user_isloggedin(){
//This func will only work with superglobla arrays
//because $supersecret_hash_padding. $LOGGED_IN:
//Have we already run the hash checks ?
//IF so $ return the pre-set var
if (isSet($LOGGED_IN)) {
return $LOGGED_IN;
}
if ($_COOKIE['user_name'] && COOKIE['id_hash']) {
$hash = md5($_COOKIE['user_name'].$supersecrect_hash_padding);
if ($hash == $_COOKIE['id_hash']) {
return trun;
} else {
return false;
}
} else {
return false;
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.170.140.79
※ 编辑: previa 来自: 218.170.140.79 (05/02 23:30)
※ 编辑: previa 来自: 218.170.140.79 (05/02 23:43)
2F:推 previa:这个我有看过了 可是还是不懂为什麽要先设false再unset 05/03 02:35
3F:推 cyuyi:不先设定值的话,是不是会有警告讯息?? 05/03 04:27
4F:推 mmss33:没有看书怎麽知道 不过我猜$LOGIN_IN是区域变数 05/03 13:09
5F:→ mmss33:$LOGGED_IN是全域变数 一开始设false是要你重新登入一次 05/03 13:11
6F:→ mmss33:我不是高手 所以说错不管 ^_< 05/03 13:12
7F:推 previa:感谢 了解了^^ 05/04 00:58