標題:
運用session做計數器
[打印本頁]
作者:
may
時間:
2013-6-18 21:25
標題:
運用session做計數器
<?php
header('Content-Type:text/html; charset=utf-8');
session_start();
if(empty($_SESSION['counter'])){ //empty:判斷變數是否為空值
//為空值
//echo '沒有值';
$_SESSION['counter'] = 1;
}else{
//不為空值
//echo '有值';
//$_SESSION['counter'] = $_SESSION['counter'] + 1;
//$_SESSION['counter']+=1;
$_SESSION['counter']++;
}
echo $_SESSION['counter'];
?>
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2