会员
周边
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
李超
cc编程笔记本。
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
::
公告
PHP5的__get与__set
php5中class有了__get和__set这两个方法。
代码:
Code
class
Test
{
private
$propertys
=
array
();
function
__set(
$property
,
$value
)
{
$this
->
propertys[
$property
]
=
$value
;
}
function
__get(
$property
)
{
return
$this
->
propertys[
$property
];
}
}
在访问一个对象并不拥有的属性时,如果该对象用户__get和__set方法,则会自动调用__get方法或__set方法
posted on
2009-06-06 22:55
coderlee
阅读(
283
) 评论(
0
)
收藏
举报
刷新页面
返回顶部