游客:
注册
|
登录
|
帮助
网友俱乐部
»
网络编程
»
PHP教程
» 使用str-replace而不是ereg-replace
网友生活网
|
网友学堂
如何获得金币?
诚招斑竹
IP归属地查询 PR查询 收录查询 whois查询
免费超短2级域名,your.jpy.cc
传世私服
|
传奇世界私服
注册亚洲交友中心,找个人来同居吧!
免费存储空间,免费网络硬盘
‹‹ 上一主题
|
下一主题 ››
投票
交易
悬赏
活动
打印
|
推荐
|
订阅
|
收藏
标题: 使用str-replace而不是ereg-replace
问天
元帅
UID 11493
精华
187
积分 34221
帖子 33355
威望 91
金币 13148
热心 2619
阅读权限 100
注册 2006-4-7
状态 离线
#1
使用道具
发表于 2007-2-20 01:16
资料
个人空间
主页
短消息
加为好友
使用str-replace而不是ereg-replace
php4比php3新加了session的支持。稍微用了一下,对其函数接口,内部机制,
应用的方便性做了大概的了解。
session的意义大家都应该清楚,一个session可以包括数次http的请求和应答,
比如我们用163.net,从login到logout或者超时就作为一个session,session
的唯一标识一般是在系统内部生成一个唯一的session ID,一般是一个挺长的
字符串。一个session除了session ID,还可以有自己的session data,可以
记录和区分sesion的不同状态。
php4对session操作提供以下接口:
session_start &;#8212; Initialize session data
session_destroy &;#8212; Destroys all data registered to a session
session_name &;#8212; Get and/or set the current session name
session_module_name &;#8212; Get and/or set the current session module
session_save_path &;#8212; Get and/or set the current session save path
session_id &;#8212; Get and/or set the current session id
session_register &;#8212; Register a variable with the current session
session_unregister &;#8212; Unregister a variable from the current session
session_is_registered &;#8212; Find out if a variable is registered in a session
session_decode &;#8212; Decodes session data from a string
session_encode &;#8212; Encodes the current session data as a string
意义大家一看就能明白,session_start开始一个session,session_destroy结
束一个session,session_id取得当前的session_id,session_register向当前
的session注册一个变量,这个很有用,比如用户逛商场,选中了某几样商品你
就可以用session_register把商品名称或者代码register到当前的session中。
比如下面例子(摘自php manual):
<?php
session_register("count");
$count ;
?>
Hello visitor, you have seen this page <? echo $count; ?> times.<p>
# the <?=SID?> is necessary to preserve the session id
# in the case that the user has disabled cookies
To continue, <A HREF="nextpage.php?<?=SID?>">click here</A>
session_register可以隐式地激发session_start(如果用户之前没发session_
start调用),当前的session注册了一个变量count,每次用户点击click here
的时候,这个变量都会增一。你可以自己试一下。<?=SID?>的意义不多赘述。
网友
问天
签名 - 网友社区
请您回个帖。谢谢
PR查询
免费域名
免费空间
[广告]
免费域名(Free Subdomain)
免费空间(Free hosting)
PR查询(Google Pagerank)
投票
交易
悬赏
活动
控制面板首页
编辑个人资料
积分交易
公众用户组
好友列表
个人空间管理
基本概况
流量统计
客户软件
发帖量记录
论坛排行
主题排行
发帖排行
积分排行
在线时间
管理团队
管理统计
当前时区 GMT+8, 现在时间是 2008-11-21 12:27
信产部ICP备案:
京ICP备05066424号
北京市公安局网监备案:1101050648号
Powered by
Discuz!
5.5.0
TOP
清除 Cookies
-
联系我们
-
网友俱乐部
-
Archiver
-
WAP