作者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