开发者

How to use $this->methodname in PHP session_set_save_handle?

I have a Session class that has all my on_session_write, on_session_read etc. methods inside the class. In my constructor function i have it initiate the

session_set_save_handler("on_session_start",   "开发者_StackOverflow社区on_session_end",
        "on_session_read",    "on_session_write",
        "on_session_destroy", "on_session_gc");

and also session_start() within this my only problem is the methods need to be called using $this-> because everything is within the class. How do i accomplish this?


It's very simple:

array($this,'methodName'); 

That's a callback to a method.

array('className','methodName');

That's a callback to a static method.


You can pass array($this, 'methodName') as an argument. Read more on http://php.net/manual/en/language.pseudo-types.php(dead link)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜