Topic: Calling class methods

I just wanted to see if my understanding of xajax registration is correct.  The xajax project I've been tasked with updating registers a number of class methods as callbacks, so you might have something like this:

class MyClass {
public function myMethod() {}
}
$xajax = new xajax();
$xajax->registerFunction(array("myMethodTrigger", "MyClass", "myMethod"));

My understanding is that when this hits, xajax is doing some sort of static call to MyClass::myMethod (call_user_func or whatever) - it ISN'T creating an instance of MyClass to call the method?  At least, I couldn't catch it doing so.  In theory, this would be throwing a warning like "Non-static method MyClass::myMethod() should not be called statically" if E_STRICT error reporting was set?  To be picky, in a modern world methods to be registered for xajax calls should be declared Static?

Also, registerFunction is marked as deprecated.  I don't know what the plans for the future were, but I took a quick look at "register" and it seems to support registering either a global function or an entire object, but not an object method.  Registering an object apparently registers all the public methods in it, giving the same picky issue with non-static?

Re: Calling class methods

Hi,

Look at this thread. http://community.xajaxproject.org/topic … functions/

What you need is:

$func = new FuncXajax();
$xajax->register(XAJAX_CALLABLE_OBJECT,$func);

You can call any public method in the class.

Call it like so

onSomeEvant="xajax_func.functionName()"

Note the class name you use is the instance name...

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.