[請益] 關於php5 & Mysql5聖經

看板PHP作者時間19年前 (2006/05/02 23:26), 編輯推噓5(502)
留言7則, 3人參與, 最新討論串1/1
想請問一下 裡面的有個地方 我不知道為什麼作者要用這個函式說 不知道動機為何@@ 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)

05/03 00:10, , 1F

05/03 02:35, , 2F
這個我有看過了 可是還是不懂為什麼要先設false再unset
05/03 02:35, 2F

05/03 04:27, , 3F
不先設定值的話,是不是會有警告訊息??
05/03 04:27, 3F

05/03 13:09, , 4F
沒有看書怎麼知道 不過我猜$LOGIN_IN是區域變數
05/03 13:09, 4F

05/03 13:11, , 5F
$LOGGED_IN是全域變數 一開始設false是要你重新登入一次
05/03 13:11, 5F

05/03 13:12, , 6F
我不是高手 所以說錯不管 ^_<
05/03 13:12, 6F

05/04 00:58, , 7F
感謝 瞭解了^^
05/04 00:58, 7F
文章代碼(AID): #14LteVBT (PHP)
文章代碼(AID): #14LteVBT (PHP)