PHP中 $_SESSION[]變量的使用

在PHP中SESSION是保存在服務器端的文件,session文件的路徑可在php.ini文件中找到,以xampp爲例:C:/xampp/tmp。經常用變量$_SESSION來儲存臨時信息,如用$_SESSION['cart']來臨時存儲傳遞購物車信息,在應用此變量的時候,最好直接用$_SESSION['cart']作爲引用 ,若另指定變量名稱($cart=$_SESSION['cart']),容易在變量的傳遞過程中出現怪異的問題。


Note : This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章