Click to See Complete Forum and Search --> : [RESOLVED] session_set_save_handler in a class syntax .....


whisher06
01-29-2007, 08:46 AM
Hi.
Could anybody explain me this syntax, please ?

public function setHandler()
{
session_set_save_handler(array($this,'openSession'),array($this,'closeSession'),array($this,'readSession'),array($this,'writeSession'),array($this,'destroySession'),array($this,'gcSession'));
}



Thanks in advance.


Bye.

dream.scape
01-29-2007, 10:51 AM
Functions that you pass a callback function name to, you can usually make them call an object instance and method by passing an array in the form array($object, 'method').

example:
// call $my_object->my_method();
call_user_func(array($my_object, 'my_method'));

You can even do static calls on callbacks by passing array('class', 'method'). Example:
// call my_class::my_method();
call_user_func(array('my_class', 'my_method'));

And of course, setting a callback as a function:
// call my_function();
call_user_func('my_function');

Not sure if I explained that well enough, but I hope it helps. :-)

whisher06
01-29-2007, 04:16 PM
Thanks so much buddy for the enlightenment ;)

Bye.