- <?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'];
- ?>
複製代碼 |