session_register()出错的解决办法
错误提示:warning: unknown(): your script possibly relies on a session side-effect which
existed until php 4.2.3. please be advised that the session extension does not
consider global variables as a source of data, unless register_globals is
enabled. you can disable this functionality and this warning by setting
session.bug_compat_42 or session.bug_compat_warn to off, respectively. in unknown on line 0
1、php4.2以上版本不需要用session_register()注册session变量,直接用:
$_session["string"]=“string";
赋值。
2、用$_session["string"]获取变量值。
3、用$_session["string"][$n]可传递session数组。
两个测试页面:
//a.php
session_start();
echo $_session["x"]++;
//b.php
session_start();
echo $_session["x"];
运行a.php并不断刷新它,看看有什么结果
运行b.php看看能否在页面之间传送结果。
注意:a.php和b.php必须是同一个ie进程!
测试在register_globals = off下进行,一切正常。