<?php session_start(); $count = 0; $count = $_SESSION['count']; $_SESSION['count']++; ?> U have been here <?=$_SESSION['count'];?> times.
楼上的代码错误提示为 Notice: Undefined variable: _SESSION in d:\usr\www\html\forum\test1.php on line 3Notice: Undefined variable: _SESSION in d:\usr\www\html\forum\test1.php on line 4Notice: Undefined index: count in d:\usr\www\html\forum\test1.php on line 4
楼主,用你的代码在我机器上测试没有问题,是不是你的php中的session项没配置好?
为什么 <? session_start();?> <? echo "shenhu"; session_register("count"); $count++; echo $count; ?> 的显示是 shenhu1 shenhu2 shenhu3 ....而<?php session_start();$count = 0; $count = $_SESSION['count']; $_SESSION['count']++; ?> U have been here <?=$_SESSION['count'];?> times.的显示始终是1谁能解释解释?
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().
直接用$_SESSION 好了啊
我怎么使用一个session会话
session_start()
echo session_id();//显示出seesion_ID
?>
就可以了
register_globals
这一项
register_globals=on
session_start(); $count = 0;
$count = $_SESSION['count'];
$_SESSION['count']++;
?>
U have been here <?=$_SESSION['count'];?> times.
Notice: Undefined variable: _SESSION in d:\usr\www\html\forum\test1.php on line 3Notice: Undefined variable: _SESSION in d:\usr\www\html\forum\test1.php on line 4Notice: Undefined index: count in d:\usr\www\html\forum\test1.php on line 4
<? session_start();?>
<? echo "shenhu";
session_register("count");
$count++;
echo $count;
?>
的显示是
shenhu1
shenhu2
shenhu3
....而<?php
session_start();$count = 0;
$count = $_SESSION['count'];
$_SESSION['count']++;
?>
U have been here <?=$_SESSION['count'];?> times.的显示始终是1谁能解释解释?
将php.ini的虚拟路径改为实际路径就行
session.save_path = ./tmp
改为
session.save_path = c:\winnt\temp
<? echo "shenhu";
session_register("count");
$count++;
echo $count;
?>
第一个是因为你没有给count赋值,就直接用session里的值咯.
而第二个是每次都重新赋值咯,$count = 0;所以session保存了也无效.
$count=0;
$_SESSION['count']=$count;
}$_SESSION['count']+=1;echo $_SESSION['count'];