Re: Function name must be a string error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux