Re: Function name must be a string error

From: Date: Wed, 05 Dec 2018 10:10:37 +0000
Subject: Re: Function name must be a string error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-326618@lists.php.net to get a copy of this message
On 04.12.2018 at 02:01, Jeffry Killen wrote: > self::$_proc(/*args*/) // -> Function name must be a string If you used the recommended setting for error_reporting during development, you'd gotten a more useful error notice; something like: Notice: Undefined variable: _proc in %s on line %d The problem is that PHP thinks that $_proc(/*args*/) should be called to get the name of the property of self, i.e. it basically does: $temp = $_proc(/*args*/); self::$temp; This obviously isn't what you've intended. You can work around that in PHP 5 by doing something like: $temp = self::$_proc; $temp(/*args*/); As of PHP 7.0.0 you can use the following instead (like Enno already wrote): (self::$_proc)(/*args*/); -- Christoph M. Becker

« previous php.general (#326618) next »