一个简单的 session 使用 <? session_start(); //注册一个session变量 session_register('counter'); //增加计数器 $counter++; echo "You have visited this page $counter times! Don't you have anything else to do, you bum?!"; //session_start(); //session_register('count'); //$count++; //echo "<P>You've been here $count times.</p>"; ?> session_start -- Initialize session data bool session_start ( void ) session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie. This function always returns TRUE. 注: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser. session_register -- Register one or more global variables with the current session bool session_register ( mixed name [, mixed ...] ) session_register() accepts a variable number of arguments, any of which can be either a string holding the name of a variable or an array consisting of variable names or other arrays. For each name, session_register() registers the global variable with that name in the current session. 结果 调试警告 - 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. 声明:O:\php\Apache Group\Apache2\htdocs\t1\t2.php 行 6 - Undefined variable: counter 访问的时候一片空白,源码成了这样 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=gb2312"></HEAD> <BODY></BODY></HTML> 不知道是不是由于我修改了PHP.INI?或者ZEND自己又一套PHP,两个乱七八糟的 错误应用程序 Apache.exe,版本 2.0.54.0,错误模块 ntdll.dll,版本 5.1.2600.1106,错误地址 0x000267cd。 反正我决定彻底的重新安装一遍。 ZEND不再自行安装新的PHP,直接使用原安装的。 字体:大 中 小 |