Re: $this assignment and call_user_func question

From: Date: Tue, 15 Jul 2003 22:18:56 +0000
Subject: Re: $this assignment and call_user_func question
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-3431@lists.php.net to get a copy of this message
On Wed, 2003-07-16 at 00:08, Greg Beaver wrote: > Hi, [...] As Marcus already replied on this part and as I agree, I'll leave out any comments:) > In addition, will call_user_func() support static methods before 1.0? > call_user_func('class::method', $args); This is already supported (in PHP4). Simply use array("class", "method") for the first argument instead of array($instance, "method"). thekid@friebes:~ > php -r 'class Foo { function bar($arg) { var_dump($arg, $this); echo "--\n"; }} call_user_func(array("Foo", "bar"), "static"); call_user_func(array(new Foo(), "bar"), "non-static");' string(6) "static" NULL -- string(10) "non-static" object(foo)(0) { } -- $this is NULL for the call via array("Foo", "bar") - meaning this method has been called statically. thekid@friebes:~ > php -v PHP 4.3.1 (cli) (built: Feb 23 2003 20:37:24) Copyright (c) 1997-2002 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies - Timm

« previous php.internals (#3431) next »